home *** CD-ROM | disk | FTP | other *** search
/ Your Choice 1 / your choice.zip / your choice / PRGMMING / VISIONIX / VCRTU.PAS < prev    next >
Pascal/Delphi Source File  |  1993-12-30  |  161KB  |  8,327 lines

  1. {
  2.  ════════════════════════════════════════════════════════════════════════════
  3.  
  4.  Visionix CRT API to VOut/VIn Unit (VCRT)
  5.    Version 0.13
  6.  Copyright 1991,92,93 Visionix
  7.  ALL RIGHTS RESERVED
  8.  
  9.  ────────────────────────────────────────────────────────────────────────────
  10.  
  11.  Revision history in reverse chronological order:
  12.  
  13.  Initials  Date      Comment
  14.  ────────  ────────  ────────────────────────────────────────────────────────
  15.  
  16.  jrt       12/28/93  Added TextColors, GotoX, GotoY
  17.  
  18.  jrt       12/05/93  Modified to reflect changes to VOUTu wherein
  19.                      VOutSubChanNew and VOutFilterAttach now have
  20.                      three driver parameters instead of one.
  21.  
  22.  jrt       11/28/93  Added MakeAttr function.
  23.  
  24.  jrt       11/10/93  Finished RegionFillXXX functions.
  25.  
  26.  jrt       11/10/93  Added CRTOutDriverProc cases for ODF_Regionxxx
  27.  
  28.  jrt       07/10/93  Converted to use start of new VOUT chan/subchan/filter
  29.                      architecture.
  30.  
  31.  rag       05/18/93  Added FillRegionAttr.
  32.  
  33.  jrt       05/16/93  Changed carriage return/line feed values because
  34.                      mike and rob said they were wrong.
  35.                      IT WAS MY FAULT.  Sincerely, Jon
  36.  
  37.  mep       03/26/93  Added usage of VBios.
  38.  
  39.  lpg       03/15/93  Added Source Documentation
  40.  
  41.  mep       02/11/93  Cleaned up code for beta release
  42.  
  43.  jrt       02/08/93  Sync with beta 0.12 release
  44.  
  45.  jrt       02/08/93  Added support to automatically determine the
  46.                      screen size by supporting the new VOutGetScreenSize
  47.                      function.
  48.  
  49.  jrt       12/07/92  Sync with beta 0.11 release
  50.  
  51.  jrt       12/07/92  Fixed bug in TextBackGround that would allow
  52.                      "high-intensity" background colors to be set,
  53.                      which in fact would just set the blink attribute on.
  54.                      Only bits 0-1-2 of background color are valid now.
  55.  
  56.  jrt       12/01/92  Yanked VGACharWidthSet, moved it into VFont.
  57.  
  58.  jrt       12/01/92  Yanked console info functions, moved them to
  59.                      Vequip.  Was this a good decision?  Who knows.
  60.  
  61.  jrt       11/21/92  Sync with beta 0.08
  62.  
  63.  jrt       10/26/92  Fixed two bugs:  one fixed "mangling" of the attr
  64.                      setting be making textattr := knowntextattr in the
  65.                      syncattr routine.  The other fixed the improper
  66.                      scrolling of windows when a writeln occured at the
  67.                      bottom of the window.
  68.  
  69.  jrt       09/01/92  First logged revision.
  70.  
  71.  --------------------------------------------------------------------------
  72.  
  73.  Notes:
  74.  
  75.    yank VGAcharwidthset, it is now in VFont.
  76.  
  77.    yank console info obtaining functions, they are now in VEquip.
  78.    As a result, figure out what to do with VCRTGetCaps.
  79.  
  80.  ════════════════════════════════════════════════════════════════════════════
  81. }
  82.  
  83.  
  84. (*-
  85.  
  86. [SECTION: Section 2: The Text I/O Libraries]
  87. [CHAPTER: Chapter 2: The CRT API replacement unit]
  88.  
  89. [TEXT]
  90.  
  91. <Overview>
  92.  
  93. VCRTu is a Turbo Pascal CRT replacement unit.  It implements all
  94. of the functions found in the TP CRT unit, and adds many new functions.
  95.  
  96. VCRTu is an interface layer on top of VOUTu and VINu.  Calls to
  97. VCRTu functions are completed by calling the appropriate VOUTu or
  98. VINu function.
  99.  
  100. VCRTu automatically creates a CRT output channel and a sub-channel
  101. which sends its output to the primary local video display.
  102.  
  103. <<Whats all that mean>>
  104.  
  105.   Basically, VCRTu replaces CRT.  VCRTu does all of its work through
  106.   a fast, flexible, and comprehensive text input and output architecture
  107.   which is based on the concept of text input and output channels
  108.   and sub-channels.  By default, VCRTu automatically creates a
  109.   text output channel and sub-channel which goes to the primary
  110.   video display, and a text input channel and sub-channel which goes
  111.   to the keyboard.  VCRT then does all of its work via these channels.
  112.   For example, when you call ClrScr, VCRT calls VOutClrScr with the
  113.   handle of the CRT output channel.  When you call ReadKey, VCRT
  114.   calls VInReadKey with the handle of the CRT input channel.
  115.  
  116.   By attaching filters to the CRT sub-channel you can enhance or modify
  117.   the output capabilities of your application.  For example, you
  118.   can attach the AnsiFilter to the CRT sub-channel to make it possible
  119.   to use ANSI commands in your Write or WriteLn statements.
  120.  
  121.   By creating new sub-channels off of the CRT channel, you can direct
  122.   the output of your program to other devices, such as the serial port.
  123.   This creates a flexable foundation for BBS programs or DOOR programs.
  124.  
  125.   For more information, see the VOUTu and VINu chapters.
  126.  
  127. <Interface>
  128.  
  129. -*)
  130.  
  131. Unit VCRTu;
  132.  
  133. Interface
  134.  
  135. Uses
  136.  
  137.   VTypesu,
  138.   VInu,
  139.   VOutu,
  140. {$IFNDEF OS2}
  141.   VBiosu,
  142. {$ELSE}
  143.   VVioI,
  144. {$ENDIF}
  145.  
  146. {$IFDEF DEBUG}
  147.   VDEBUGU,
  148. {$ENDIF}
  149.  
  150.   DOS;
  151.  
  152. {────────────────────────────────────────────────────────────────────────────}
  153.  
  154. Const
  155.  
  156.   {-------------}
  157.   { Video Modes }
  158.   {-------------}
  159.  
  160.   BW40           = 0;
  161.   CO40           = 1;
  162.   C40            = CO40;
  163.   BW80           = 2;
  164.   CO80           = 3;
  165.   C80            = CO80;
  166.   Mono           = 7;
  167.   Font8x8        = 256;
  168.  
  169.   {--------}
  170.   { Colors }
  171.   {--------}
  172.  
  173.   Black          = 0;
  174.   Blue           = 1;
  175.   Green          = 2;
  176.   Cyan           = 3;
  177.   Red            = 4;
  178.   Magenta        = 5;
  179.   Brown          = 6;
  180.   LightGray      = 7;
  181.   DarkGray       = 8;
  182.   LightBlue      = 9;
  183.   LightGreen     = 10;
  184.   LightCyan      = 11;
  185.   LightRed       = 12;
  186.   LightMagenta   = 13;
  187.   Yellow         = 14;
  188.   White          = 15;
  189.   Blink          = 128;
  190.  
  191.   BackBlack      = 0 SHL 4;
  192.   BackBlue       = 1 SHL 4;
  193.   BackGreen      = 2 SHL 4;
  194.   BackCyan       = 3 SHL 4;
  195.   BackRed        = 4 SHL 4;
  196.   BackMagenta    = 5 SHL 4;
  197.   BackBrown      = 6 SHL 4;
  198.   BackLightGray  = 7 SHL 4;
  199.  
  200.   {--------------------------------------------------------}
  201.   { Card & monitor types for CRT Capabilities (CrtGetCaps) }
  202.   {--------------------------------------------------------}
  203.  
  204.   cCardNone      = $00;
  205.   cCardVGA       = $01;
  206.   cCardEGA       = $02;
  207.   cCardMDA       = $03;
  208.   cCardHGC       = $04;
  209.   cCardCGA       = $05;
  210.  
  211.   cMonitorNone       = $00;
  212.   cMonitorMono       = $01;
  213.   cMonitorColor      = $02;
  214.   cMonitorEGAHiRes   = $03;
  215.   cMonitorAnaMono    = $04;
  216.   cMonitorAnaColor   = $05;
  217.  
  218.   {--------------------------------------------}
  219.   { Color attribute to monochrome atribute map }
  220.   {--------------------------------------------}
  221.  
  222.   MonoMap : Array[0..255] of BYTE = (
  223.             {00} $00, $01, $07, $07, $07, $07, $07, $07,
  224.                  $07, $07, $07, $07, $07, $07, $0F, $0F,
  225.             {10} $70, $01, $07, $07, $07, $07, $07, $07,
  226.                  $07, $07, $07, $07, $07, $07, $0F, $0F,
  227.             {20} $70, $70, $70, $70, $70, $70, $70, $70,
  228.                  $70, $70, $70, $70, $70, $70, $70, $70,
  229.             {30} $70, $70, $70, $70, $70, $70, $70, $70,
  230.                  $70, $70, $70, $70, $70, $70, $70, $70,
  231.             {40} $70, $70, $70, $70, $70, $70, $70, $70,
  232.                  $70, $70, $70, $70, $70, $70, $70, $70,
  233.             {50} $70, $70, $70, $70, $70, $70, $70, $70,
  234.                  $70, $70, $70, $70, $70, $70, $70, $70,
  235.             {60} $70, $70, $70, $70, $70, $70, $70, $70,
  236.                  $70, $70, $70, $70, $70, $70, $70, $70,
  237.             {70} $70, $70, $70, $70, $70, $70, $70, $70,
  238.                  $70, $70, $70, $70, $70, $70, $70, $70,
  239.             {80} $80, $81, $87, $87, $87, $87, $87, $87,
  240.                  $87, $87, $87, $87, $87, $87, $8F, $8F,
  241.             {90} $F0, $81, $87, $87, $87, $87, $87, $87,
  242.                  $87, $87, $87, $87, $87, $87, $8F, $8F,
  243.             {A0} $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,
  244.                  $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,
  245.             {B0} $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,
  246.                  $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,
  247.             {C0} $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,
  248.                  $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,
  249.             {D0} $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,
  250.                  $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,
  251.             {E0} $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,
  252.                  $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,
  253.             {F0} $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,
  254.                  $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0     );
  255.  
  256.  
  257.  
  258. Type
  259.  
  260.   {------------------------}
  261.   { CRT System Information }
  262.   {------------------------}
  263.  
  264.   TCRTSystem = RECORD
  265.  
  266.      Card          : BYTE;
  267.      Monitor       : BYTE;
  268.  
  269.   END;
  270.  
  271.   PCRTSystem = ^TCRTSystem;
  272.  
  273.   {----}
  274.  
  275.   {----------------------------------------}
  276.   { CRT Capabilities & Info for CrtGetCaps }
  277.   {----------------------------------------}
  278.  
  279.   TCRTCaps   = RECORD
  280.  
  281.     actdisplay     : byte;
  282.     altdisplay     : byte;
  283.  
  284.     CRTSystem      : Array[1..2] of TCRTSystem;
  285.  
  286.     CurMode        : BYTE;
  287.  
  288.   END;
  289.  
  290.   PCRTCaps   = ^TCRTCaps;
  291.  
  292.  
  293.   TCRTColorMap = Array[0..255] of BYTE;
  294.  
  295.   PCrtColorMap = ^TCRTColorMap;
  296.  
  297.  
  298. {────────────────────────────────────────────────────────────────────────────}
  299.  
  300.  
  301. Procedure CRTGetCaps(             Caps           : PCRTCaps  );
  302.  
  303. Function  CRTIsVGA                                             : BOOLEAN;
  304.  
  305. Function  CRTIsMono                                            : BOOLEAN;
  306.  
  307. Procedure CRTVGASetCharWidth(     CWid           : BYTE      );
  308.  
  309. Procedure CRTOutDriverProc(       ODP            : POutDriverPacket );
  310.  
  311.  
  312. {$IFDEF OS2}
  313. Procedure VIOOutDriverProc(       ODP            : POutDriverPacket );
  314. {$ENDIF}
  315.  
  316.  
  317. Procedure CRTInDriverProc(        IDP            : PInDriverPacket );
  318.  
  319. Procedure CRTLoadColorMap(   P : PCRTColorMap    );
  320.  
  321. Procedure CRTLoadMonoColorMap;
  322.  
  323. Procedure CRTLoadDefColorMap;
  324.  
  325.  
  326. Procedure AssignCRT(          Var F              : TEXT      );
  327.  
  328. Procedure ClrEOL;
  329.  
  330. Procedure ClrScr;
  331.  
  332. Procedure Delay(                  MS             : WORD      );
  333.  
  334. Procedure DelLine;
  335.  
  336. Procedure GotoXY(                 X              : BYTE;
  337.                                   Y              : BYTE      );
  338.  
  339. Procedure HighVideo;
  340.  
  341. Procedure InsLine;
  342.  
  343. Function  KeyPressed                                           : BOOLEAN;
  344.  
  345. Procedure LowVideo;
  346.  
  347. Procedure NormVideo;
  348.  
  349. Procedure NoSound;
  350.  
  351. Function  ReadKey                                              : CHAR;
  352.  
  353. Procedure Sound(                  HZ             : WORD      );
  354.  
  355. Procedure TextBackGround(         Color          : BYTE      );
  356.  
  357. Procedure TextColor(              Color          : BYTE      );
  358.  
  359. Procedure TextMode(               Mode           : INTEGER   );
  360.  
  361. Function  WhereX                                               : BYTE;
  362.  
  363. Function  WhereY                                               : BYTE;
  364.  
  365. Procedure Window(                 X1             : BYTE;
  366.                                   Y1             : BYTE;
  367.                                   X2             : BYTE;
  368.                                   Y2             : BYTE      );
  369.  
  370.  
  371. {---------------------}
  372. { VCRT Sync Functions }
  373. {---------------------}
  374.  
  375. Procedure SyncAttr;
  376.  
  377. Procedure SyncWind;
  378.  
  379.  
  380. {-------------------------}
  381. { VCRT Enhanced functions }
  382. {-------------------------}
  383.  
  384. Procedure WindowScreen;
  385.  
  386.  
  387. { Change text attribute }
  388.  
  389. Function  TextColorGet                                         : BYTE;
  390.  
  391. Function  TextBackgroundGet                                    : BYTE;
  392.  
  393. Procedure TextColors(             Fore           : BYTE;
  394.                                   Back           : BYTE      );
  395.  
  396. Procedure TextAttrSet(            Attr           : BYTE      );
  397.  
  398.  
  399. { cursor movement commands }
  400.  
  401. Procedure CursorUp(               Count          : BYTE      );
  402.  
  403. Procedure CursorDown(             Count          : BYTE      );
  404.  
  405. Procedure CursorLeft(             Count          : BYTE      );
  406.  
  407. Procedure CursorRight(            Count          : BYTE      );
  408.  
  409.  
  410. { screen store read functions }
  411.  
  412. Function  CharRead(               X1             : BYTE;
  413.                                   Y1             : BYTE      ) : CHAR;
  414.  
  415. Function  AttrRead(               X1             : BYTE;
  416.                                   Y1             : BYTE      ) : BYTE;
  417.  
  418. Procedure AttrWrite(              X1             : BYTE;
  419.                                   Y1             : BYTE;
  420.                                   Attr           : BYTE      );
  421.  
  422.  
  423. { Region Functions }
  424.  
  425. Function  RegionMemQuery(         X1             : BYTE;
  426.                                   Y1             : BYTE;
  427.                                   X2             : BYTE;
  428.                                   Y2             : BYTE      ) : WORD;
  429.  
  430. Procedure RegionScrollUp(         X1             : BYTE;
  431.                                   Y1             : BYTE;
  432.                                   X2             : BYTE;
  433.                                   Y2             : BYTE;
  434.                                   Count          : BYTE      );
  435.  
  436. Procedure RegionScrollDown(       X1             : BYTE;
  437.                                   Y1             : BYTE;
  438.                                   X2             : BYTE;
  439.                                   Y2             : BYTE;
  440.                                   Count          : BYTE      );
  441.  
  442. Procedure RegionRead(             X1             : BYTE;
  443.                                   Y1             : BYTE;
  444.                                   X2             : BYTE;
  445.                                   Y2             : BYTE;
  446.                                   Region         : Pointer   );
  447.  
  448. Procedure RegionWrite(            X1             : BYTE;
  449.                                   Y1             : BYTE;
  450.                                   X2             : BYTE;
  451.                                   Y2             : BYTE;
  452.                                   Region         : Pointer   );
  453.  
  454. Procedure RegionCopy(             X1             : BYTE;
  455.                                   Y1             : BYTE;
  456.                                   X2             : BYTE;
  457.                                   Y2             : BYTE;
  458.                                   ToX1           : BYTE;
  459.                                   ToY1           : BYTE      );
  460.  
  461. Procedure RegionFill(             X1             : BYTE;
  462.                                   Y1             : BYTE;
  463.                                   X2             : BYTE;
  464.                                   Y2             : BYTE;
  465.                                   Ch             : CHAR;
  466.                                   F              : BYTE;
  467.                                   B              : BYTE      );
  468.  
  469. Procedure RegionFillAttr(         X1             : BYTE;
  470.                                   Y1             : BYTE;
  471.                                   X2             : BYTE;
  472.                                   Y2             : BYTE;
  473.                                   Attr           : BYTE      );
  474.  
  475.  
  476. Procedure RegionFillColors(       X1             : BYTE;
  477.                                   Y1             : BYTE;
  478.                                   X2             : BYTE;
  479.                                   Y2             : BYTE;
  480.                                   F              : BYTE;
  481.                                   B              : BYTE      );
  482.  
  483. Procedure RegionFillChar(         X1             : BYTE;
  484.                                   Y1             : BYTE;
  485.                                   X2             : BYTE;
  486.                                   Y2             : BYTE;
  487.                                   Ch             : CHAR      );
  488.  
  489.  
  490. { RegionFillString??? }
  491.  
  492. Procedure RepeatChar(             Ch             : CHAR;
  493.                                   Num            : WORD      );
  494.  
  495. Procedure RepeatCharAt(           X1             : BYTE;
  496.                                   Y1             : BYTE;
  497.                                   F              : BYTE;
  498.                                   B              : BYTE;
  499.                                   Ch             : CHAR;
  500.                                   Num            : WORD      );
  501.  
  502. Procedure WriteCharAt(                 X1        : BYTE;
  503.                                        Y1        : BYTE;
  504.                                        F         : BYTE;
  505.                                        B         : BYTE;
  506.                                        Ch        : CHAR      );
  507.  
  508. Procedure WriteStringAt(               X1        : BYTE;
  509.                                        Y1        : BYTE;
  510.                                        F         : BYTE;
  511.                                        B         : BYTE;
  512.                                        S         : STRING    );
  513.  
  514. Procedure WriteRepeatString(           RepCount  : WORD;
  515.                                        S         : STRING    );
  516.  
  517.  
  518. { cursor control }
  519.  
  520.  
  521. Procedure CursorOn;
  522. Procedure CursorOff;
  523. Procedure CursorSmall;
  524. Procedure CursorHalf;
  525. Procedure CursorBig;
  526.  
  527.  
  528. { misc }
  529.  
  530.  
  531. Function  MakeAttr(                    F         : INTEGER;
  532.                                        B         : INTEGER   ) : BYTE;
  533.  
  534.  
  535.  
  536.  
  537. Var
  538.  
  539.   CheckBreak      : BOOLEAN; { standard CRT variables ... }
  540.   CheckEOF        : BOOLEAN;
  541.   DirectVideo     : BOOLEAN;
  542.   CheckSnow       : BOOLEAN;
  543.   LastMode        : WORD;
  544.   TextAttr        : BYTE;
  545.  
  546.   Font8x8Selected : BOOLEAN;
  547.  
  548.   WindMin         : WORD;
  549.   WindMax         : WORD;
  550.  
  551.   WindCenterCol   : BYTE;    { center column on the primary display }
  552.   WindCenterRow   : BYTE;    { center row on the primary display    }
  553.  
  554.   ScreenRows      : BYTE;    { number of rows on the primary display }
  555.   ScreenCols      : BYTE;    { number of cols on the primary display }
  556.  
  557.   KnownTextAttr   : BYTE;    { used to do SYNC operations }
  558.   KnownWindMin    : WORD;    { used to do SYNC operations }
  559.   KnownWindMax    : WORD;    { used to do SYNC oeprations }
  560.  
  561.   CrtODNErr       : WORD;    { used by vin/vout }
  562.  
  563.   CrtOCH          : TChanHandle; { Handle VCRu uses with VOUTu }
  564.  
  565.   CrtColorMap     : Array[0..255] of BYTE;  { active TEXTATTR color map }
  566.  
  567.   TF              : TEXT;    { for debug log file testing }
  568.  
  569. {────────────────────────────────────────────────────────────────────────────}
  570.  
  571. Implementation
  572.  
  573. {
  574.  
  575. Uses
  576.   VAnsiIOu;
  577.  
  578. }
  579.  
  580. Const
  581.  
  582.   DelayOfMS : Word = 0;
  583.  
  584.  
  585. {--------------------------------------------}
  586. { Types and functions used when in OS/2 mode }
  587. {--------------------------------------------}
  588.  
  589. {$IFDEF OS2}
  590.  
  591. Type
  592.  
  593.   TKbdKeyInfo = RECORD
  594.  
  595.     chChar    : Char;
  596.     chScan    : Char;
  597.     fbStatus  : Byte;
  598.     bNlsShift : Byte;
  599.     fsState   : Word;
  600.     time      : LongInt;
  601.  
  602.   End;
  603.  
  604.   PKbdKeyInfo = ^TKbdKeyInfo;
  605.  
  606.  
  607. Function  KbdCharIn(          Var KeyInfo             : TKbdKeyInfo;
  608.                                   Wait                : Word;
  609.                                   KbdHandle           : Word    ) : Word; Far;
  610.  
  611.   External 'KBDCALLS' Index 4;
  612.  
  613.  
  614.  
  615. Function  KbdPeek(            Var KeyInfo             : TKbdKeyInfo;
  616.                                   KbdHandle           : WORD    ) : WORD; Far;
  617.  
  618.   External 'KBDCALLS' Index 22;
  619.  
  620.  
  621.  
  622. Function  DosSleep(               Time                : LONGINT ) : WORD; Far;
  623.  
  624.     External 'DOSCALLS' Index 32;
  625.  
  626.  
  627. {$ENDIF}
  628.  
  629.  
  630.  
  631. {────────────────────────────────────────────────────────────────────────────}
  632.  
  633. (*-
  634.  
  635. [FUNCTION]
  636.  
  637. Procedure CRTGetCardAndMonInfo(   C              : PCRTCaps  );
  638.  
  639. [PARAMETERS]
  640.  
  641. C           Pointer to Video Capacity Structure
  642.  
  643. [RETURNS]
  644.  
  645. (Function : None)
  646. (Ptr      : [C] Pointer to Video Capacity Structure)
  647.  
  648. [DESCRIPTION]
  649.  
  650. This function fills in the CRT capabilities structure pointed to by
  651. "C" with information about the current CRT systems.
  652.  
  653. This function is mainly for internal use.  The CrtGetCaps function
  654. should be used in place of this one.
  655.  
  656. [SEE-ALSO]
  657.  
  658. CrtGetCaps
  659.  
  660. [EXAMPLE]
  661.  
  662. -*)
  663.  
  664. Procedure CRTGetCardAndMonInfo(   C              : PCRTCaps  );
  665.  
  666. Var
  667.  
  668.   ShouldCheckVGA  : BOOLEAN;
  669.   ShouldCheckEGA  : BOOLEAN;
  670.   ShouldCheckMono : BOOLEAN;
  671.   ShouldCheckCGA  : BOOLEAN;
  672.  
  673. {$IFNDEF OS2}
  674.   R               : REGISTERS;
  675. {$ENDIF}
  676.  
  677.   {────────────────────────────────────────────────────────────────────────}
  678.  
  679. {$IFNDEF OS2}
  680.  
  681.   Function  CheckFor6845(         Port           : WORD      ) : BOOLEAN;
  682.  
  683.   Var
  684.     Test   : BYTE;
  685.  
  686.   BEGIN
  687.  
  688.   {-------------------}
  689.   { CheckFor6845  !^! }
  690.   {-------------------}
  691.  
  692.     ASM
  693.  
  694.       MOV  DX, PORT
  695.  
  696.       MOV  AL, $0A
  697.       OUT  DX, AL
  698.       INC  DX
  699.  
  700.       IN   AL, DX
  701.       MOV  AH, AL
  702.  
  703.       CMP  AH, 4
  704.       JE   @@1
  705.  
  706.       MOV  AL, 4
  707.       JMP  @@2
  708.  
  709.     @@1:
  710.  
  711.       MOV  AL, 3
  712.  
  713.     @@2:
  714.  
  715.       OUT  DX, AL
  716.  
  717.       MOV  CX, 100
  718.  
  719.     @@3:
  720.       LOOP @@3
  721.  
  722.       IN   AL, DX
  723.       XCHG AL, AH
  724.       OUT  DX, AL
  725.  
  726.       MOV  TEST, 1
  727.       CMP  AL, AH
  728.       JNE  @@4
  729.  
  730.       MOV  TEST, 0
  731.  
  732.     @@4:
  733.  
  734.     END;  { Asm }
  735.  
  736.     CheckFor6845 := (Test=1);
  737.  
  738.   END;  { CheckFor6845 }
  739.  
  740.   {────────────────────────────────────────────────────────────────────────}
  741.  
  742.   Procedure CheckVGA;
  743.  
  744.   Const
  745.     ConvertCard : Array[0..8] of BYTE = ( cCardNone,
  746.                                           cCardMDA,
  747.                                           cCardCGA,
  748.                                           cCardNone,
  749.                                           cCardEGA,
  750.                                           cCardEGA,
  751.                                           cCardNone,
  752.                                           cCardVGA,
  753.                                           cCardVGA            );
  754.  
  755.     ConvertMon  : Array[0..8] of BYTE = ( cMonitorNone,
  756.                                           cMonitorMono,
  757.                                           cMonitorColor,
  758.                                           cMonitorNone,
  759.                                           cMonitorEGAHiRes,
  760.                                           cMonitorMono,
  761.                                           cMonitorNone,
  762.                                           cMonitorAnaMono,
  763.                                           cMonitorAnaColor    );
  764.   BEGIN
  765.  
  766.     R.ES := 0;
  767.     R.DS := 0;
  768.  
  769.     R.AX := $1A00;
  770.  
  771.     Intr( $10, R );
  772.  
  773.     If R.AL = $1A Then
  774.     BEGIN
  775.  
  776.       C^.CRTSystem[1].Card     := ConvertCard[ R.BL ];
  777.       C^.CRTSystem[1].Monitor :=  ConvertMon[ R.BL ];
  778.  
  779.       C^.CRTSystem[2].Card    := ConvertCard[ R.BH ];
  780.       C^.CRTSystem[2].Monitor :=  ConvertMon[ R.BH ];
  781.  
  782.       ShouldCheckCGA := FALSE;
  783.       ShouldCheckEGA := FALSE;
  784.  
  785.       If C^.CRTSystem[1].Card = cCardMDA Then
  786.       BEGIN
  787.  
  788.         C^.CRTSystem[1].Card  := cCardNone
  789.  
  790.       END  { If C^.CRTSystem[1].Card }
  791.  
  792.       Else
  793.  
  794.         If C^.CRTSystem[2].Card = cCardMDA Then
  795.         BEGIN
  796.  
  797.           C^.CRTSystem[2].Card := cCardNone
  798.  
  799.         END  { If C^.CRTSystem[2].Card }
  800.  
  801.         Else
  802.         BEGIN
  803.  
  804.           If C^.CRTSystem[2].Card <> cCardNone Then
  805.             ShouldCheckMono := FALSE;
  806.  
  807.         END;  { If C^.CRTSystem[2].Card / Else }
  808.  
  809.     END;  { If R.AL }
  810.  
  811.   END;  { CheckVGA }
  812.  
  813.   {────────────────────────────────────────────────────────────────────────}
  814.  
  815.   Procedure FoundCRTSystem(       Card, Monitor  : BYTE      );
  816.  
  817.   BEGIN
  818.  
  819.     IF C^.CRTSystem[1].Card = cCardNone Then
  820.     BEGIN
  821.  
  822.       C^.CRTSystem[1].Card    := Card;
  823.       C^.CRTSystem[1].Monitor := Monitor;
  824.  
  825.     END  { If C^.CRTSystem[1].Card }
  826.  
  827.     ELSE
  828.     BEGIN
  829.  
  830.       C^.CRTSystem[2].Card    := Card;
  831.       C^.CRTSystem[2].Monitor := Monitor;
  832.  
  833.     END;  { If C^.CRTSystem[1].Card / Else }
  834.  
  835.   END;  { FoundCRTSystem }
  836.  
  837.   {────────────────────────────────────────────────────────────────────────}
  838.  
  839.   Procedure CheckEGA;
  840.  
  841.   Var
  842.     MonType : BYTE;
  843.  
  844.   Const
  845.     ConvertDips : Array[0..5] of BYTE = ( cMonitorColor,
  846.                                           cMonitorEGAHiRes,
  847.                                           cMonitorMono,
  848.                                           cMonitorColor,
  849.                                           cMonitorEGAHiRes,
  850.                                           cMonitorMono          );
  851.  
  852.   BEGIN
  853.  
  854.     R.AH := $12;
  855.     R.BL := $10;
  856.  
  857.     R.ES := $0;
  858.     R.DS := $0;
  859.  
  860.     Intr( $10, R );
  861.  
  862.     If R.BL <> $10 Then
  863.     BEGIN
  864.  
  865.       ShouldCheckCGA := FALSE;
  866.  
  867.       MonType := ConvertDips[ ((R.CL SHR 1) AND $0F) ];
  868.  
  869.       FoundCRTSystem( cCardEGA, MonType );
  870.  
  871.       If MonType = cMonitorMono Then
  872.         ShouldCheckMono := FALSE;
  873.  
  874.     END; { if R.BL }
  875.  
  876.   END;  { CheckEGA }
  877.  
  878.   {────────────────────────────────────────────────────────────────────────}
  879.  
  880.   Procedure CheckCGA;
  881.  
  882.   BEGIN
  883.  
  884.     If CheckFor6845( $3D4 ) Then
  885.     BEGIN
  886.  
  887.       FoundCRTSystem( cCardCGA, cMonitorColor );
  888.  
  889.     END;  { CheckFor6845 }
  890.  
  891.   END;  { CheckCGA }
  892.  
  893.   {────────────────────────────────────────────────────────────────────────}
  894.  
  895.   Procedure CheckMono;
  896.  
  897.   Var
  898.  
  899.     CardType : BYTE;
  900.  
  901.   BEGIN
  902.  
  903.     { Check Mono }
  904.  
  905.     If CheckFor6845( $3B4 ) Then
  906.     BEGIN
  907.  
  908.     { Found Mono-6845 }
  909.  
  910.       ASM
  911.  
  912.         MOV  DX, $3BA
  913.         IN   AL, DX
  914.         AND  AL, $80
  915.         MOV  AH, AL
  916.  
  917.         MOV  CX, $8000
  918.  
  919.       @@1:
  920.         IN   AL, DX
  921.         AND  AL, $80
  922.         CMP  AL, AH
  923.         JNE  @@2
  924.         LOOP @@1
  925.  
  926.         MOV  CardType, cCardMDA
  927.         JMP  @@3
  928.  
  929.       @@2:
  930.         MOV  CardType, cCardHGC
  931.  
  932.       @@3:
  933.  
  934.       END; { Asm }
  935.  
  936.       FoundCRTSystem( CardType, cMonitorMono );
  937.  
  938.     END; { If CheckFor6845 }
  939.  
  940.   END; { CheckMono }
  941.  
  942.   {────────────────────────────────────────────────────────────────────────}
  943.  
  944.   Procedure SwapCRTSystems;
  945.  
  946.   Var
  947.  
  948.     Temp : TCRTSystem;
  949.  
  950.   BEGIN
  951.  
  952.     Temp := C^.CRTSystem[1];
  953.     C^.CRTSystem[1] := C^.CRTSystem[2];
  954.     C^.CRTSystem[2] := Temp;
  955.  
  956.   END;  { SwapCRTSystems }
  957.  
  958.   {────────────────────────────────────────────────────────────────────────}
  959.  
  960. {$ENDIF} { os/2 }
  961.  
  962. BEGIN { Procedure CRTGetCardAndMonInfo }
  963.  
  964.  
  965. {$IFDEF OS2}
  966.   C^.CurMode := 3;
  967.   C^.CrtSystem[1].Card    := cCardVGA;
  968.   C^.CrtSystem[1].Monitor := cMonitorAnaColor;
  969.   C^.CrtSystem[2].Card    := CCardNone;
  970. {$ELSE}
  971.   ShouldCheckVga  := TRUE;
  972.   ShouldCheckEGA  := TRUE;
  973.   ShouldCheckMono := TRUE;
  974.   ShouldCheckCGA  := TRUE;
  975.  
  976.   C^.CRTSystem[1].Card     := cCardNone;
  977.   C^.CRTSystem[1].Monitor  := cMonitorNone;
  978.   C^.CRTSystem[2].Card     := cCardNone;
  979.   C^.CRTSystem[2].Monitor  := cMonitorNone;
  980.  
  981.   If ShouldCheckVGA Then
  982.     CheckVGA;
  983.   If ShouldCheckEGA Then
  984.     CheckEGA;
  985.   If ShouldCheckCGA Then
  986.     CheckCGA;
  987.   If ShouldCheckMono Then
  988.     CheckMono;
  989.  
  990.   If (C^.CRTSystem[1].Card<>cCardVGA) and
  991.      (C^.CRTSystem[2].Card<>cCardVGA) Then
  992.   BEGIN
  993.  
  994.     R.AH := $0F;
  995.     R.ES := $0;
  996.     R.DS := $0;
  997.  
  998.     Intr( $10, R );
  999.  
  1000.     If R.AL = $07 Then
  1001.     BEGIN
  1002.  
  1003.       If (C^.CRTSystem[1].Monitor<>cMonitorMono) Then
  1004.         SwapCRTSystems;
  1005.  
  1006.     END  { If R.AL }
  1007.  
  1008.     ELSE
  1009.     BEGIN
  1010.  
  1011.       If (C^.CRTSystem[1].Monitor=cMonitorMono) Then
  1012.         SwapCRTSystems;
  1013.  
  1014.     END;  { If R.AL / Else }
  1015.  
  1016.   END; { If C^.CRTSystem[1].Card } { IF No VGA }
  1017.  
  1018.   R.AH := $0F;
  1019.   R.ES := $0;
  1020.   R.DS := $0;
  1021.  
  1022.   Intr( $10, R );
  1023.  
  1024.   C^.CurMode := R.AL;
  1025.  
  1026.  
  1027. {$ENDIF} { os/2 }
  1028.  
  1029. END; { CRTGetCardAndMonInfo }
  1030.  
  1031. {────────────────────────────────────────────────────────────────────────────}
  1032.  
  1033. (*-
  1034.  
  1035. [FUNCTION]
  1036.  
  1037. Procedure CRTGetCaps(             Caps           : PCRTCaps  );
  1038.  
  1039. [PARAMETERS]
  1040.  
  1041. Caps         Pointer to Video Capacity Structure
  1042.  
  1043. [RETURNS]
  1044.  
  1045. (Function : None)
  1046. (Ptr      : [C] Pointer to CRT Capabilities Structure)
  1047.  
  1048. [DESCRIPTION]
  1049.  
  1050. This function fills in the CRT capabilities structure pointed to by
  1051. "Caps" with information about the current CRT systems.  A CRT system
  1052. is a video card and monitor combination.  The PC can have two
  1053. CRT systems installed--a primary and an alternate.  Typically,
  1054. the primary is either cga/ega/vga/hercules/mono, and the alternate, if
  1055. present, is hercules/mono.
  1056.  
  1057.  
  1058. <CRT Capabilities Structure>
  1059.  
  1060.  
  1061.   TCRTCaps   = RECORD
  1062.  
  1063.     actdisplay     : byte;
  1064.     altdisplay     : byte;
  1065.  
  1066.     CRTSystem      : Array[1..2] of TCRTSystem;
  1067.  
  1068.     CurMode        : BYTE;
  1069.  
  1070.   END;
  1071.  
  1072.   actdisplay           is no longer used
  1073.   altdisplay           is no longer used
  1074.  
  1075.   CRTSystem[1].Card    = disply card for the primary CRT system
  1076.   CRTSystem[1].Monitor = monitor for the primary CRT system
  1077.  
  1078.   CRTSystem[2].Card    = disply card for the secondary CRT system
  1079.   CRTSystem[2].Monitor = monitor for the secondary CRT system
  1080.  
  1081.   CurMode              = video mode the primary CRT system is
  1082.                          currently in.
  1083.  
  1084. <<Card Types>>
  1085.  
  1086.   cCardNone      = $00;
  1087.   cCardVGA       = $01;
  1088.   cCardEGA       = $02;
  1089.   cCardMDA       = $03;
  1090.   cCardHGC       = $04;
  1091.   cCardCGA       = $05;
  1092.  
  1093. <<Monitor types>>
  1094.  
  1095.   cMonitorNone       = $00;
  1096.   cMonitorMono       = $01;
  1097.   cMonitorColor      = $02;
  1098.   cMonitorEGAHiRes   = $03;
  1099.   cMonitorAnaMono    = $04;
  1100.   cMonitorAnaColor   = $05;
  1101.  
  1102. [SEE-ALSO]
  1103.  
  1104. [EXAMPLE]
  1105.  
  1106. Var
  1107.  
  1108.   CC : TCrtCaps;
  1109.  
  1110. BEGIN
  1111.  
  1112.   CRTGetCaps( @CC );
  1113.  
  1114.   If CC.CRTSystem[2].Card=cCardNone Then
  1115.     WriteLn('An alternate CRT system is present.')
  1116.   Else
  1117.     WriteLn('No alternate CRT system is present.');
  1118.  
  1119.  
  1120. END;
  1121.  
  1122. -*)
  1123.  
  1124. Procedure CRTGetCaps(             Caps           : PCRTCaps  );
  1125.  
  1126. BEGIN
  1127.  
  1128.   {------------------------}
  1129.   { Get current video mode }
  1130.   {------------------------}
  1131.  
  1132.   {---------------------------}
  1133.   { Get primary and alternate }
  1134.   { display types             }
  1135.   {---------------------------}
  1136.  
  1137.   CRTGetCardAndMonInfo( Caps );
  1138.  
  1139.  
  1140. END;  { CRTGetCaps }
  1141.  
  1142. {────────────────────────────────────────────────────────────────────────────}
  1143.  
  1144. (*-
  1145.  
  1146. [FUNCTION]
  1147.  
  1148. Function CRTIsVGA                                              : BOOLEAN;
  1149.  
  1150. [PARAMETERS]
  1151.  
  1152. (None)
  1153.  
  1154. [RETURNS]
  1155.  
  1156. Whether the primary CRT system is VGA.
  1157.  
  1158. [DESCRIPTION]
  1159.  
  1160. Checks to see if the primary CRT system is VGA.
  1161.  
  1162. Returns TRUE if the primary CRT system is a VGA display.
  1163. Returns FALSE if the primary is anything other than VGA.
  1164.  
  1165. [SEE-ALSO]
  1166.  
  1167. CrtIsMono
  1168. CrtGetCaps
  1169.  
  1170. [EXAMPLE]
  1171.  
  1172.   If CrtIsVga Then
  1173.     WriteLn(' The primary CRT is VGA.')
  1174.   Else
  1175.     WriteLn(' The primary CRT is non-VGA.');
  1176.  
  1177. -*)
  1178.  
  1179. Function CRTIsVGA                                              : BOOLEAN;
  1180.  
  1181. Var
  1182.   Caps : TCRTCaps;
  1183.  
  1184. BEGIN
  1185.  
  1186.   CRTGetCaps(@Caps);
  1187.  
  1188.   CRTIsVGA := Caps.CRTSystem[1].Card = cCardVGA;
  1189.  
  1190.   (*
  1191.   CRTIsVga := (Caps.ActDisplay In[ $07..$08 ]) AND (Caps.CurMode<>7);
  1192.   *)
  1193.  
  1194. END;  { CRTIsVGA }
  1195.  
  1196. {────────────────────────────────────────────────────────────────────────────}
  1197.  
  1198. (*-
  1199.  
  1200. [FUNCTION]
  1201.  
  1202. Function CRTIsMono                                             : BOOLEAN;
  1203.  
  1204. [PARAMETERS]
  1205.  
  1206. (None)
  1207.  
  1208. [RETURNS]
  1209.  
  1210. Whether the primary CRT system is monochrome/hercules monochrome.
  1211.  
  1212. [DESCRIPTION]
  1213.  
  1214. Returns TRUE if the primary CRT system is a monochrome display.
  1215. Returns FALSE if the primary is anything other than monochrome.
  1216.  
  1217. [SEE-ALSO]
  1218.  
  1219. CrtIsVga
  1220. CrtGetCaps
  1221.  
  1222. [EXAMPLE]
  1223.  
  1224.   If CrtIsMono Then
  1225.     WriteLn(' The primary CRT is moncohrome/hercules monochrome.')
  1226.   Else
  1227.     WriteLn(' The primary CRT is not monochrome/hercules.');
  1228.  
  1229. -*)
  1230.  
  1231. Function CRTIsMono                                             : BOOLEAN;
  1232.  
  1233. Var
  1234.   Caps : TCRTCaps;
  1235.  
  1236. BEGIN
  1237.  
  1238.   CRTGetCaps(@Caps);
  1239.  
  1240.   CRTIsMono := (Caps.ActDisplay In[ $01..$01 ]) or (Caps.CurMode=7);
  1241.  
  1242. END;  { CRTIsMono }
  1243.  
  1244. {────────────────────────────────────────────────────────────────────────────}
  1245.  
  1246. (*-
  1247.  
  1248. [FUNCTION]
  1249.  
  1250. Procedure CRTOutDriverProc(       ODP            : POutDriverPacket );
  1251.  
  1252. [PARAMETERS]
  1253.  
  1254. ODP         Pointer to Output Driver Packet
  1255.  
  1256. [RETURNS]
  1257.  
  1258. (None)
  1259.  
  1260. [DESCRIPTION]
  1261.  
  1262. This function is used internally by VCRTu and VOUTu.
  1263.  
  1264. This is a CRT output driver procedure that is used by VOUTu.
  1265. This function receives request from VOUTu to perform text output
  1266. operations, and performs the request on the current primary video
  1267. card.
  1268.  
  1269. All TP CRT API functions in VCRTu (I.E: GotoXY, Write, ClrScr, Etc)
  1270. are performed by calling the appropriate function in VOUTu.
  1271.  
  1272. It should not be necessary for anyone other than VCRTu and VOUTu
  1273. to call or use this function.
  1274.  
  1275. See VOUTu for more information.
  1276.  
  1277.  
  1278.  
  1279. [SEE-ALSO]
  1280.  
  1281. [EXAMPLE]
  1282.  
  1283. -*)
  1284.  
  1285. Procedure CRTOutDriverProc(       ODP            : POutDriverPacket );
  1286.  
  1287. Type
  1288.  
  1289.   TCharBuff = Array[1..32768] of CHAR;
  1290.   PCharBuff = ^TCharBuff;
  1291.  
  1292.   {----}
  1293.  
  1294.   TCell = Record
  1295.  
  1296.     Char    : CHAR;
  1297.     Attr    : BYTE;
  1298.  
  1299.   END;  { TCell }
  1300.  
  1301.   {----}
  1302.  
  1303.   TScreenStore = Array[0..32000] of TCell;
  1304.  
  1305.   PScreenStore = ^TScreenStore;
  1306.  
  1307.   {----}
  1308.  
  1309.   TScreen = RECORD
  1310.  
  1311.     CurX      : WORD;
  1312.     CurY      : WORD;
  1313.     CurAttr   : BYTE;
  1314.  
  1315.     WinX1     : WORD;
  1316.     WinX2     : WORD;
  1317.     WinY1     : WORD;
  1318.     WinY2     : WORD;
  1319.  
  1320.     CurType   : WORD;
  1321.  
  1322.     ScreenSize: WORD;
  1323.  
  1324.     S         : PScreenStore;
  1325.  
  1326.   END;  { TScreen }
  1327.  
  1328.   PScreen = ^TScreen;
  1329.  
  1330.   {----}
  1331.  
  1332.   TCRTOutDriverIData = Record
  1333.  
  1334.     Off        : WORD;
  1335.     Name       : TProcName;
  1336.  
  1337.     VirtualCRT : BOOLEAN;
  1338.  
  1339.     DisplayMode: BYTE;
  1340.  
  1341.     Cols       : WORD;
  1342.     Rows       : WORD;
  1343.  
  1344.     YMult      : WORD;
  1345.  
  1346.     NumScreens : BYTE;
  1347.  
  1348.     AScreen    : BYTE;
  1349.  
  1350.     Screen     : Array[1..8] of TScreen;
  1351.  
  1352.     MyODP      : TOutDriverPacket;
  1353.  
  1354.   END;  { TCRTOutDriverIData }
  1355.  
  1356.   PCRTOutDriverIData = ^TCRTOutDriverIData;
  1357.  
  1358.   {----}
  1359.  
  1360.   TVCRTDriverInfo = RECORD
  1361.  
  1362.     Cols    : WORD;
  1363.     Rows    : WORD;
  1364.     Screens : WORD;
  1365.  
  1366.   END;  { TVCRTDriverInfo }
  1367.  
  1368.   PVCRTDriverInfo = ^TVCRTDriverInfo;
  1369.  
  1370.   MyPByte = ^Byte;
  1371.   MyPWord = ^Word;
  1372.  
  1373. Var
  1374.  
  1375.   IData      : PCRTOutDriverIData;
  1376.   YMult      : WORD;
  1377.  
  1378.   AS         : PScreen;
  1379.  
  1380.   Z          : INTEGER;
  1381.   Z2         : INTEGER;
  1382.   Z3         : INTEGER;
  1383.  
  1384.   SaveCurX   : WORD;
  1385.   SaveCurY   : WORD;
  1386.  
  1387.   CallNext   : BOOLEAN;
  1388.  
  1389.   {────────────────────────────────────────────────────────────────────────}
  1390.  
  1391.   Procedure InitCRTIdata;
  1392.  
  1393.   Type
  1394.     MyPtrWord = ^WORD;
  1395.  
  1396.   Var
  1397.  
  1398.   {$IFNDEF OS2}
  1399.     R        : REGISTERS;
  1400.   {$ENDIF}
  1401.     Z        : INTEGER;
  1402.     StoreOfs : WORD;
  1403.  
  1404.   BEGIN
  1405.  
  1406.  
  1407.     {$IFDEF OS2}
  1408.  
  1409.       {---------------------------------------}
  1410.       { Determine CRT type; mono, hercules-1, }
  1411.       { hercules-2, hercules in-color, cga,   }
  1412.       { ega, or vga                           }
  1413.       {---------------------------------------}
  1414.  
  1415.       IData^.DisplayMode := 0;
  1416.  
  1417.       {----------------------}
  1418.       { Determine CRT mode,  }
  1419.       { active screen/page,  }
  1420.       { and number of cols   }
  1421.       {----------------------}
  1422.  
  1423.       IData^.DisplayMode := 3;
  1424.  
  1425.       IData^.AScreen     := 1;
  1426.  
  1427.       IData^.Cols        := 80;
  1428.  
  1429.       IData^.YMult       := IData^.Cols;
  1430.  
  1431.       {---------------------}
  1432.       { Determine # of rows }
  1433.       {---------------------}
  1434.  
  1435.       IData^.Rows := 25;
  1436.  
  1437.       If Idata^.Rows<25 Then
  1438.         Idata^.Rows := 25;
  1439.  
  1440.       {------------------------------}
  1441.       { Determine # of screens/pages }
  1442.       {------------------------------}
  1443.  
  1444.       IData^.NumScreens := 1;
  1445.  
  1446.       {------------------------------}
  1447.       { Determine if Font8x8 is used }
  1448.       {------------------------------}
  1449.  
  1450.       { If Vga and rows=50 then yes }
  1451.  
  1452.       { If Ega and rows=43 then yes }
  1453.  
  1454.       {--------------------------------------------------}
  1455.       { Check for DV, Win, OS/2, Topview, Doubledos, etc }
  1456.       {--------------------------------------------------}
  1457.  
  1458.       { look it up }
  1459.  
  1460.       {-----------------------}
  1461.       { Get information       }
  1462.       { For each display page }
  1463.       {-----------------------}
  1464.  
  1465.       For Z:= 1 to IData^.NumScreens Do
  1466.       BEGIN
  1467.  
  1468.         {--------------------}
  1469.         { Get cursor X and Y }
  1470.         {--------------------}
  1471.  
  1472.         IData^.Screen[Z].CurX := 1;
  1473.         IData^.Screen[Z].CurY := 1;
  1474.  
  1475.         {-----------------}
  1476.         { Get cursor type }
  1477.         {-----------------}
  1478.  
  1479.         { set it and sync the crt }
  1480.  
  1481.         {-----------------------}
  1482.         { Get Current Attribute }
  1483.         {-----------------------}
  1484.  
  1485.         IData^.Screen[Z].CurAttr := 7;
  1486.  
  1487.         {--------------------}
  1488.         { Init window coords }
  1489.         {--------------------}
  1490.  
  1491.         { call visionix services to determine window coords }
  1492.  
  1493.         IData^.Screen[Z].WinX1 := 0;
  1494.         IData^.Screen[Z].WinY1 := 0;
  1495.         IData^.Screen[Z].WinX2 := IData^.Cols-1;
  1496.         IData^.Screen[Z].WinY2 := IData^.Rows-1;
  1497.  
  1498.         {----------------------------}
  1499.         { Get Pointer to screen/page }
  1500.         {----------------------------}
  1501.  
  1502.         IData^.Screen[Z].S     := NIL;
  1503.  
  1504.         { we can't get the pointers to each page }
  1505.         { until we switch to the page.  we can,  }
  1506.         { however, get the pointer to the active }
  1507.         { page, which we will do later.          }
  1508.  
  1509.  
  1510.       END; { For Z := 1 to numscreens/pages }
  1511.  
  1512.  
  1513.       {---------------------------------}
  1514.       { get a pointer to the vid buffer }
  1515.       {---------------------------------}
  1516.  
  1517.       VioGetBuf( Pointer(IData^.Screen[ 1 ].S),
  1518.                  IData^.Screen[1].ScreenSize, 0 );
  1519.  
  1520.  
  1521.     {$ELSE}
  1522.  
  1523.       {---------------------------------------}
  1524.       { Determine CRT type; mono, hercules-1, }
  1525.       { hercules-2, hercules in-color, cga,   }
  1526.       { ega, or vga                           }
  1527.       {---------------------------------------}
  1528.  
  1529.       IData^.DisplayMode := 0;
  1530.  
  1531.       {----------------------}
  1532.       { Determine CRT mode,  }
  1533.       { active screen/page,  }
  1534.       { and number of cols   }
  1535.       {----------------------}
  1536.  
  1537.       R.AH := $0F;
  1538.       R.ES := $0;
  1539.       R.DS := $0;
  1540.  
  1541.       Intr( $10, R );
  1542.  
  1543.       IData^.DisplayMode := R.AL;
  1544.  
  1545.       IData^.AScreen     := R.BH+1;
  1546.  
  1547.       IData^.Cols        := R.AH;
  1548.  
  1549.       IData^.YMult       := IData^.Cols;
  1550.  
  1551.       {---------------------}
  1552.       { Determine # of rows }
  1553.       {---------------------}
  1554.  
  1555.       IData^.Rows := Succ(BiosMemMap^.VidVGACurrRow);
  1556.  
  1557.       If Idata^.Rows<25 Then
  1558.         Idata^.Rows := 25;
  1559.  
  1560.       {------------------------------}
  1561.       { Determine # of screens/pages }
  1562.       {------------------------------}
  1563.  
  1564.       IData^.NumScreens := 8;
  1565.  
  1566.       {------------------------------}
  1567.       { Determine if Font8x8 is used }
  1568.       {------------------------------}
  1569.  
  1570.       { If Vga and rows=50 then yes }
  1571.  
  1572.       { If Ega and rows=43 then yes }
  1573.  
  1574.       {--------------------------------------------------}
  1575.       { Check for DV, Win, OS/2, Topview, Doubledos, etc }
  1576.       {--------------------------------------------------}
  1577.  
  1578.       { look it up }
  1579.  
  1580.       {-----------------------}
  1581.       { Get information       }
  1582.       { For each display page }
  1583.       {-----------------------}
  1584.  
  1585.       For Z:= 1 to IData^.NumScreens Do
  1586.       BEGIN
  1587.  
  1588.         {--------------------}
  1589.         { Get cursor X and Y }
  1590.         {--------------------}
  1591.  
  1592.         R.AH :=$03;
  1593.         R.BH :=Z-1;
  1594.         R.ES :=$0;
  1595.         R.DS :=$0;
  1596.  
  1597.         Intr( $10, R );
  1598.  
  1599.         IData^.Screen[Z].CurX := R.DL;
  1600.         IData^.Screen[Z].CurY := R.DH;
  1601.  
  1602.         {-----------------}
  1603.         { Get cursor type }
  1604.         {-----------------}
  1605.  
  1606.         { set it and sync the crt }
  1607.  
  1608.         {-----------------------}
  1609.         { Get Current Attribute }
  1610.         {-----------------------}
  1611.  
  1612.         R.AH := $08;
  1613.         R.BH := Z-1;
  1614.         R.ES := $0;
  1615.         R.DS := $0;
  1616.  
  1617.         Intr( $10, R );
  1618.  
  1619.         IData^.Screen[Z].CurAttr := (R.AH AND $7F);
  1620.  
  1621.         {--------------------}
  1622.         { Init window coords }
  1623.         {--------------------}
  1624.  
  1625.         { call visionix services to determine window coords }
  1626.  
  1627.         IData^.Screen[Z].WinX1 := 0;
  1628.         IData^.Screen[Z].WinY1 := 0;
  1629.         IData^.Screen[Z].WinX2 := IData^.Cols-1;
  1630.         IData^.Screen[Z].WinY2 := IData^.Rows-1;
  1631.  
  1632.         {----------------------------}
  1633.         { Get Pointer to screen/page }
  1634.         {----------------------------}
  1635.  
  1636.         IData^.Screen[Z].S     := NIL;
  1637.  
  1638.         { we can't get the pointers to each page }
  1639.         { until we switch to the page.  we can,  }
  1640.         { however, get the pointer to the active }
  1641.         { page, which we will do later.          }
  1642.  
  1643.  
  1644.       END; { For Z := 1 to numscreens/pages }
  1645.  
  1646.       {-----------------------------------------}
  1647.       { Get offset to current page/screen/store }
  1648.       {-----------------------------------------}
  1649.  
  1650.       StoreOfs := BiosMemMap^.VidCurrPageAddr SHR 4;
  1651.  
  1652.       {-------------------------------------}
  1653.       { build pointer to active page/screen }
  1654.       {-------------------------------------}
  1655.  
  1656.       If CrtIsMono = TRUE THen
  1657.         IData^.Screen[ IData^.Ascreen ].S := Ptr( SegB000, $00 )
  1658.  
  1659.       Else
  1660.         IData^.Screen[ IData^.Ascreen ].S := Ptr( SegB800+StoreOfs, $00 );
  1661.  
  1662.     {$ENDIF}
  1663.  
  1664.   END; { InitCRTIData }
  1665.  
  1666.  
  1667. (*
  1668.  
  1669.   Procedure OutChars(             Count          : WORD;
  1670.                                   Buff           : POINTER;
  1671.                                   CurX,CurY      : PBYTE;
  1672.                                   CurAttr        : BYTE;
  1673.                                   X1,Y1,X2,Y2    : BYTE;
  1674.                                   VidMem         : POINTER;
  1675.                                   YMult          : BYTE     ); Assembler;
  1676.  
  1677.  
  1678.   Var
  1679.  
  1680.     LocalCurX : BYTE;
  1681.     LocalCurY : BYTE;
  1682.     DoneSoFar : WORD;
  1683.  
  1684.   ASM
  1685.  
  1686.  
  1687.     { get vars local }
  1688.  
  1689.     LEA BX, CurX
  1690.     MOV AL, byte PTR ES:[BX]
  1691.     MOV LocalCurX, AL
  1692.  
  1693.     LEA BX, CurY
  1694.     MOV AL, byte PTR ES:[BX]
  1695.     MOV LocalCurY, AL
  1696.  
  1697.     MOV DoneSoFar, 0
  1698.  
  1699.   @@TIMEAROUND:
  1700.  
  1701.     { last column? }
  1702.  
  1703.  
  1704.     CMP localCurX, X2
  1705.     JBE @@COLUMN_OK
  1706.     MOV localCurX, X1
  1707.     INC localCurY
  1708.  
  1709.     { last row?    }
  1710.  
  1711.     CMP LocalCurY, Y2
  1712.     JBE @@ROW_OK
  1713.     DEC localCurY
  1714.  
  1715.  
  1716.     { yep, scroll da sucker }
  1717.  
  1718.     MOV AH, 6
  1719.     MOV BH, CurAttr
  1720.     MOV AL, 1
  1721.     MOV CH, X1
  1722.     MOV CL, Y1
  1723.     MOV DL, X2
  1724.     MOV DH, Y2
  1725.  
  1726.     INT 10h
  1727.  
  1728.     { get count we can do this time around }
  1729.  
  1730.     MOV   CX, LocalCurX
  1731.     SUB   CX, X2
  1732.  
  1733.     MOV   AL, CurAttr
  1734.  
  1735.     { make ds:si point to source }
  1736.  
  1737.     PUSH  word PTR[Buff+2]
  1738.     POP   DS
  1739.     MOV   BX, word PTR[BUFF]
  1740.     ADD   BX, DoneSoFar
  1741.     MOV   SI, BX
  1742.  
  1743.     { make es:di point to dest }
  1744.  
  1745.     PUSH   word PTR [VidMem+2]
  1746.     POP    ES
  1747.     MOV    BX, word PTR [VidMem]
  1748.  
  1749.     MOV    AL, LocalCurY
  1750.     MUL    AL, YMult
  1751.     ADD    AL, X1
  1752.     ADD    AL, X1
  1753.     ADD    AL, LocalCurX
  1754.     ADD    AL, LocalCurX
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.   END;
  1763.  
  1764.  
  1765. *)
  1766.  
  1767.   {────────────────────────────────────────────────────────────────────────}
  1768.  
  1769.   {$IFDEF OS2}
  1770.  
  1771.   Procedure SyncScreen;
  1772.  
  1773.   BEGIN
  1774.  
  1775.     VioShowBuf( 0, AS^.ScreenSize, 0 );
  1776.  
  1777.   END;
  1778.  
  1779.   {$ENDIF}
  1780.  
  1781.   {---------}
  1782.  
  1783.   Procedure RegionScroll(         X1,Y1,X2,Y2    : WORD;
  1784.                                   Count          : INTEGER   );
  1785.  
  1786.   Var
  1787.  
  1788.     Z : INTEGER;
  1789.     CL: INTEGER;
  1790.  
  1791.     P : POINTER;
  1792.  
  1793.     NC: TCell;
  1794.  
  1795.     Wid : WORD;
  1796.  
  1797.   BEGIN
  1798.  
  1799.  
  1800.     Wid := (X2-X1)+1;
  1801.  
  1802.     NC.Char := ' ';
  1803.     NC.Attr := AS^.CurAttr;
  1804.  
  1805.     If Count<0 Then
  1806.     BEGIN
  1807.  
  1808.       { scroll up }
  1809.  
  1810.       For CL:=1 to Abs(Count) Do
  1811.       BEGIN
  1812.  
  1813.         For Z:= Y1 To Pred(Y2) Do
  1814.         BEGIN
  1815.  
  1816.           Move( AS^.S^[ ((Z+1)*YMult)+X1 ],
  1817.                 AS^.S^[ (Z*YMult)+X1     ],
  1818.                 Wid*2                         );
  1819.  
  1820.  
  1821.         END;  { For Z }
  1822.  
  1823.         P := Addr( AS^.S^[ (Y2*YMult)+X1     ] );
  1824.  
  1825.         ASM
  1826.           LES BX, [p]
  1827.           MOV AX, NC
  1828.           MOV CX, Wid
  1829.           CLD
  1830.           REPZ STOSW
  1831.         END;
  1832.  
  1833.  
  1834.       END;
  1835.  
  1836.     END
  1837.     ELSE
  1838.     BEGIN
  1839.  
  1840.       { scroll down/back }
  1841.  
  1842.       For CL:=1 to Count Do
  1843.       BEGIN
  1844.  
  1845.         For Z:= Y2 downTo Y1+1 Do
  1846.         BEGIN
  1847.  
  1848.           Move( AS^.S^[ ((Z-1)*YMult)+X1 ],
  1849.                 AS^.S^[ (Z*YMult)+X1     ],
  1850.                 Wid*2                         );
  1851.  
  1852.         END;  { For Z }
  1853.  
  1854.         P := Addr( AS^.S^[ (Y1*YMult)+X1     ] );
  1855.  
  1856.         ASM
  1857.           LES BX, [p]
  1858.           MOV AX, NC
  1859.           MOV CX, Wid
  1860.           CLD
  1861.           REPZ STOSW
  1862.         END;
  1863.  
  1864.       END;
  1865.  
  1866.       {$IFDEF OS2} SyncScreen; {$ENDIF}
  1867.  
  1868.     END;
  1869.  
  1870.   END;
  1871.  
  1872.   {────────────────────────────────────────────────────────────────────────}
  1873.  
  1874. (*-
  1875.  
  1876. [FUNCTION]
  1877.  
  1878. Procedure RegionRead(             X1,Y1,X2,Y2    : WORD;
  1879.                                   Region         : PScreenStore );
  1880.  
  1881. [PARAMETERS]
  1882.  
  1883. X1          Source Left Screen Region Coordinate
  1884. Y1          Source Top Screen Region Coordinate
  1885. X2          Source Right Region Screen Region Coordinate
  1886. Y2          Source Bottom Screen Region Coordinate
  1887. Region      Pointer to Region Read Data
  1888.  
  1889. [RETURNS]
  1890.  
  1891. (None)
  1892.  
  1893. [DESCRIPTION]
  1894.  
  1895. Reads a region from the display console to a region store buffer.
  1896. "Region" should be a pointer to a buffer which is big enough to hold
  1897. the region data.  Use RegionMemQuery to determine how many bytes must
  1898. be allocated.
  1899.  
  1900. [SEE-ALSO]
  1901.  
  1902. [EXAMPLE]
  1903.  
  1904. -*)
  1905.  
  1906.   Procedure RegionRead(           X1,Y1,X2,Y2    : WORD;
  1907.                                   Region         : PScreenStore );
  1908.   Var
  1909.     Wid  : WORD;
  1910.     Z    : INTEGER;
  1911.  
  1912.   BEGIN
  1913.  
  1914.     Wid := (X2-X1)+1;
  1915.  
  1916.     For Z:= Y1 To Y2 Do
  1917.     BEGIN
  1918.  
  1919.       Move( AS^.S^[ (Z*YMult)+X1 ], Region^[ (Z-Y1)*Wid ], Wid*2 );
  1920.  
  1921.     END;  { For Z }
  1922.  
  1923.   END;  { RegionRead }
  1924.  
  1925.   {────────────────────────────────────────────────────────────────────────}
  1926.  
  1927. (*-
  1928.  
  1929. [FUNCTION]
  1930.  
  1931. Procedure RegionWrite(            X1,Y1,X2,Y2    : WORD;
  1932.                                   Region         : PScreenStore );
  1933.  
  1934. [PARAMETERS]
  1935.  
  1936. X1          Left Screen Region Coordinate
  1937. Y1          Top Screen Region Coordinate
  1938. X2          Right Region Screen Region Coordinate
  1939. Y2          Bottom Screen Region Coordinate
  1940. Region      Pointer to Region Write Data
  1941.  
  1942. [RETURNS]
  1943.  
  1944. (None)
  1945.  
  1946. [DESCRIPTION]
  1947.  
  1948. [SEE-ALSO]
  1949.  
  1950. [EXAMPLE]
  1951.  
  1952. -*)
  1953.  
  1954.   Procedure RegionWrite(          X1,Y1,X2,Y2    : WORD;
  1955.                                   Region         : PScreenStore );
  1956.  
  1957.   Var
  1958.     Wid  : WORD;
  1959.     Z    : INTEGER;
  1960.  
  1961.   BEGIN
  1962.  
  1963.     Wid := (X2-X1)+1;
  1964.  
  1965.     For Z:= Y1 To Y2 Do
  1966.     BEGIN
  1967.  
  1968.       Move( Region^[ (Z-Y1)*Wid ], AS^.S^[ (Z*YMult)+X1 ], Wid*2 );
  1969.  
  1970.     END;  { For Z }
  1971.  
  1972.   END;  { RegionWrite }
  1973.  
  1974.   {────────────────────────────────────────────────────────────────────────}
  1975.  
  1976.   Procedure RealCursorGoto(       S,X,Y          : BYTE      );
  1977.  
  1978.   BEGIN
  1979.  
  1980.     {$IFDEF OS2}
  1981.  
  1982.       VioSetCurPos( Y, X, 0 );
  1983.  
  1984.     {$ELSE}
  1985.  
  1986.       ASM
  1987.  
  1988.         {-------------------------------}
  1989.         { Sync the actual cursor to the }
  1990.         { address CurX, CurY            }
  1991.         {-------------------------------}
  1992.  
  1993. {        PUSH DS}
  1994.  
  1995.         MOV  DH, Y
  1996.         MOV  DL, X
  1997.         MOV  BH, S
  1998.         MOV  AH, 2
  1999. {
  2000.         MOV  CX, 0
  2001.         MOV  DS, CX
  2002.         MOV  ES, CX
  2003. }
  2004.         INT  10h
  2005.  
  2006. {        POP  DS}
  2007.  
  2008.       END;
  2009.  
  2010.     {$ENDIF}
  2011.  
  2012.   END;  { RealCursorGoto }
  2013.  
  2014.   {────────────────────────────────────────────────────────────────────────}
  2015.  
  2016.   Procedure CursorDown(           Sync           : BOOLEAN   );
  2017.  
  2018.   BEGIN
  2019.  
  2020.     With AS^ Do
  2021.     BEGIN
  2022.  
  2023.       Inc( CurY );
  2024.  
  2025.       If CurY > WinY2 Then
  2026.       BEGIN
  2027.  
  2028.         RegionScroll( WinX1,
  2029.                       WinY1,
  2030.                       WinX2,
  2031.                       WinY2,
  2032.                       -1        );
  2033.  
  2034.         Dec( CurY );
  2035.  
  2036.       END;  { If CurY }
  2037.  
  2038.       If (Sync) and (IData^.VirtualCRT=FALSE) Then
  2039.         RealCursorGoto( IData^.AScreen-1, CurX, CurY );
  2040.  
  2041.     END; { With AS^ }
  2042.  
  2043.   END; { CursorDown }
  2044.  
  2045.   {────────────────────────────────────────────────────────────────────────}
  2046.  
  2047.   Procedure CursorNextChar(       Sync           : BOOLEAN   );
  2048.  
  2049.   BEGIN
  2050.  
  2051.     With   AS^ Do
  2052.     BEGIN
  2053.  
  2054.       Inc( CurX );
  2055.  
  2056.       If CurX > WinX2 Then
  2057.       BEGIN
  2058.  
  2059.         CurX := WinX1;
  2060.  
  2061.         CursorDown( Sync );
  2062.  
  2063.       END;  { If CurX }
  2064.  
  2065.       If (Sync) and (IData^.VirtualCRT=FALSE) Then
  2066.         RealCursorGoto( IData^.AScreen-1, CurX, CurY );
  2067.  
  2068.     END; { With AS^ }
  2069.  
  2070.   END; { CursorNextChar }
  2071.  
  2072.   {────────────────────────────────────────────────────────────────────────}
  2073.  
  2074.   Procedure SwapCoords( Var A,B : WORD );
  2075.  
  2076.   Var
  2077.     Temp : WORD;
  2078.  
  2079.   BEGIN
  2080.  
  2081.     Temp := A;
  2082.     A    := B;
  2083.     B    := Temp;
  2084.  
  2085.   END;  { SwapCoords }
  2086.  
  2087.   {────────────────────────────────────────────────────────────────────────}
  2088.  
  2089.   Procedure MySetCursorType( CurType : WORD );
  2090.  
  2091.   {$IFNDEF OS2}
  2092.  
  2093.   Var
  2094.  
  2095.     R : REGISTERS;
  2096.  
  2097.   BEGIN
  2098.  
  2099.     R.AH := $1;
  2100.     R.ES := $0;
  2101.     R.DS := $0;
  2102.  
  2103.     Case CurType of
  2104.  
  2105.       cctNone   : R.CX := $2000;
  2106.       cctSmall  : R.CX := $0607;
  2107.       cctHalf   : R.CX := $0407;
  2108.       cctBig    : R.CX := $0007;
  2109.  
  2110.     ELSE
  2111.       R.CX := $0607;
  2112.     END;
  2113.  
  2114.     Intr( $10, R );
  2115.  
  2116.   END;
  2117.  
  2118.   {$ELSE}
  2119.  
  2120.   BEGIN
  2121.  
  2122.   END;
  2123.  
  2124.   {$ENDIF} { if notdef os2 / else }
  2125.  
  2126.   {────────────────────────────────────────────────────────────────────────}
  2127.  
  2128.   Procedure MyClrScr;
  2129.  
  2130.   Var
  2131.  
  2132.    P   : POINTER;
  2133.    Z2  : INTEGER;
  2134.    Wid : WORD;
  2135.    NC  : TCell;
  2136.  
  2137.   BEGIN
  2138.  
  2139.     With AS^ DO
  2140.     BEGIN
  2141.  
  2142.       Wid := (WinX2-WinX1)+1;
  2143.  
  2144.       NC.Char := ' ';
  2145.       NC.Attr := AS^.CurAttr;
  2146.  
  2147.       For Z2:=WinY1 to WinY2 Do
  2148.       BEGIN
  2149.  
  2150.         P := Addr( AS^.S^[ (Z2*YMult)+WinX1     ] );
  2151.  
  2152.         ASM
  2153.           LES BX, [p]
  2154.           MOV AX, NC
  2155.           MOV CX, Wid
  2156.           CLD
  2157.           REPZ STOSW
  2158.         END;
  2159.  
  2160.       END; { For Z2 (y) }
  2161.  
  2162.       CurX := WinX1;
  2163.       CurY := WinY1;
  2164.  
  2165.       If Idata^.VirtualCRT=FALSE Then
  2166.         RealCursorGoto( IData^.Ascreen-1, CurX, Cury );
  2167.  
  2168.     END; { With AS^ }
  2169.  
  2170.  
  2171.     {$IFDEF OS2} SyncScreen; {$ENDIF}
  2172.  
  2173.   END; { myclrscr }
  2174.  
  2175.   {────────────────────────────────────────────────────────────────────────}
  2176.  
  2177.  
  2178.  
  2179.  
  2180. BEGIN  { CRTOutDriverProc }
  2181.  
  2182.   CallNext := TRUE;
  2183.  
  2184.   IData := ODP^.ID;
  2185.  
  2186.   If ODP^.Func<> ODF_DriverNew Then
  2187.   BEGIN
  2188.  
  2189.     AS    := @IData^.Screen[ IData^.AScreen ];
  2190.     YMult := IData^.YMult;
  2191.  
  2192.   END;  { ODP^.Func }
  2193.  
  2194.   If ODP^.Status = 0 Then
  2195.   BEGIN
  2196.  
  2197.     Case ODP^.Func Of
  2198.  
  2199.       ODF_WriteBlock:
  2200.       BEGIN
  2201.  
  2202.         With AS^ DO
  2203.         BEGIN
  2204.  
  2205.  
  2206.           For Z:=ODP^.Start to ODP^.Size Do
  2207.           BEGIN
  2208.  
  2209.             Case PCharBuff( ODP^.Buff)^[Z] Of
  2210.  
  2211.               #13:
  2212.               BEGIN
  2213.  
  2214.                 CurX := WinX1;
  2215.  
  2216.                 RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  2217.  
  2218.               END;  { #13 }
  2219.  
  2220.               #10:
  2221.               BEGIN
  2222.  
  2223.                 CursorDown( TRUE );
  2224.  
  2225.               END;
  2226.  
  2227.             Else
  2228.  
  2229.               S^[ (CurY*YMult)+CurX ].Char := PCharBuff( ODP^.Buff )^[Z];
  2230.               S^[ (CurY*YMult)+CurX ].Attr := CurAttr;
  2231.  
  2232.               CursorNextChar( FALSE );
  2233.  
  2234.             END;  { Case PCharBuff( ODP^.Buf)^[Z] }
  2235.  
  2236.           END; { For Z }
  2237.  
  2238.           { sync the cursor }
  2239.  
  2240.           RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  2241.  
  2242.           ODP^.Start := ODP^.Size;
  2243.  
  2244.         END; { With AS^ }
  2245.  
  2246.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  2247.  
  2248.       END;  { ODF_WriteBlock }
  2249.  
  2250.  
  2251.       {----}
  2252.  
  2253.  
  2254.       ODF_WriteChar:
  2255.       BEGIN
  2256.  
  2257.         With AS^ Do
  2258.         BEGIN
  2259.  
  2260.           Case ODP^.Ch Of
  2261.  
  2262.             #13:
  2263.             BEGIN
  2264.  
  2265.               CurX := WinX1;
  2266.  
  2267.               RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  2268.  
  2269.             END;  { #13 }
  2270.  
  2271.             #10:
  2272.             BEGIN
  2273.  
  2274.               CursorDown( TRUE );
  2275.  
  2276.             END;  { #10 }
  2277.  
  2278.           Else
  2279.  
  2280.             S^[ (CurY*YMult)+CurX ].Char := ODP^.CH;
  2281.             S^[ (CurY*YMult)+CurX ].Attr := CurAttr;
  2282.  
  2283.             CursorNextChar( TRUE );
  2284.  
  2285.           END;  { Case ODP^.Ch }
  2286.  
  2287.         END; { With AS^ }
  2288.  
  2289.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  2290.  
  2291.  
  2292.       END;  { ODF_WriteChar }
  2293.  
  2294.       {----}
  2295.  
  2296.  
  2297.       ODF_DriverNew:
  2298.       BEGIN
  2299.  
  2300.         IF @ODP^.OutDriverProc = @CRTOutDriverProc Then
  2301.         BEGIN
  2302.  
  2303.           {-------------------------}
  2304.           { Get a new Instance Data }
  2305.           { master node.            }
  2306.           {-------------------------}
  2307.  
  2308.           New( Idata );
  2309.  
  2310.  
  2311.           {---------------------------------------------------}
  2312.           { Here we check to see if we are being inited as an }
  2313.           { actual CRT memory driver or if we are beign setup }
  2314.           { as a virtual CRT driver.                          }
  2315.           {---------------------------------------------------}
  2316.  
  2317.           If ( ODP^.DriverParam1 = 0 ) or
  2318.              ( ODP^.DriverParam2 = 0 ) Then
  2319.           BEGIN
  2320.  
  2321.             Idata^.VirtualCRT := FALSE;
  2322.  
  2323.             {----------------------------------}
  2324.             { Set IData up for the CGA/EGA/VGA }
  2325.             { monochrome text display mode     }
  2326.             {----------------------------------}
  2327.  
  2328.             InitCRTIData;
  2329.  
  2330.             {--------}
  2331.             { Return }
  2332.             {--------}
  2333.  
  2334.             ODP^.Status    := ODS_Install+ODS_Changed;
  2335.  
  2336.             ODP^.ID        := IData;
  2337.  
  2338.           END  { If ODP^.Driverinfo }
  2339.  
  2340.           ELSE
  2341.           BEGIN
  2342.  
  2343.             {-------------------------------------------}
  2344.             { DriverData --> virtual CRT driverinfo, so }
  2345.             { we allocate virtual screen stores and     }
  2346.             { run in virtual CRT mode.                  }
  2347.             {-------------------------------------------}
  2348.  
  2349.             IData^.VirtualCRT := TRUE;
  2350.  
  2351.             IData^.Name       := ODP^.Name^;
  2352.             IData^.Off        := 0;
  2353.  
  2354.             IData^.Cols       := PVCRTDriverInfo( ODP^.DriverParam2 )^.Cols;
  2355.             IData^.Rows       := PVCRTDriverInfo( ODP^.DriverParam2 )^.Rows;
  2356.             IData^.NumScreens := PVCRTDriverInfo( ODP^.DriverParam2 )^.Screens;
  2357.  
  2358.             IData^.YMult      := IData^.Cols;
  2359.  
  2360.             {------------------------}
  2361.             { Get the Virtual Screen }
  2362.             { stores.                }
  2363.             {------------------------}
  2364.  
  2365.             Z := (IData^.Cols) * (IData^.Rows) * SizeOf( TCell );
  2366.  
  2367.             For Z2 := 1 to IData^.NumScreens Do
  2368.             BEGIN
  2369.               GetMem( IData^.Screen[Z2].S, Z );
  2370.  
  2371.               IData^.Screen[Z2].CurX    := 1;
  2372.               IData^.Screen[Z2].CurY    := 1;
  2373.               IData^.Screen[Z2].CurAttr := $07;
  2374.               IData^.Screen[Z2].WinX1   := 1;
  2375.               IData^.Screen[Z2].WinY1   := 1;
  2376.               IData^.Screen[Z2].WinX2   := Idata^.Cols;
  2377.               IData^.Screen[Z2].WinY2   := Idata^.Rows;
  2378.               IData^.Screen[Z2].CurType := 0;
  2379.             END;
  2380.  
  2381.             {-----------------------}
  2382.             { Set the active screen }
  2383.             {-----------------------}
  2384.  
  2385.             IData^.AScreen := 1;
  2386.  
  2387.             {--------}
  2388.             { Return }
  2389.             {--------}
  2390.  
  2391.             ODP^.Status := ODS_Install+ODS_Changed;
  2392.             ODP^.ID     := IData;
  2393.  
  2394.           END; {IF ODP^.Driverinfo / Else }
  2395.  
  2396.         END; { If ODP^.OutDriverProc --> Us }
  2397.  
  2398.       END; { ODF_DriverNew }
  2399.  
  2400.       {----}
  2401.  
  2402.       ODF_DriverOff:
  2403.       BEGIN
  2404.  
  2405.         If ODP^.Name^ = IData^.Name Then
  2406.         BEGIN
  2407.  
  2408.           Inc( Idata^.Off );
  2409.  
  2410.         END;  { If ODP^.Name^ }
  2411.  
  2412.       END;  { ODF_DriverOff }
  2413.  
  2414.       {----}
  2415.  
  2416.       ODF_DriverOn:
  2417.       BEGIN
  2418.  
  2419.         If ODP^.Name^ = IData^.Name Then
  2420.         BEGIN
  2421.  
  2422.           If Idata^.Off <> 0 Then
  2423.             Dec( Idata^.Off );
  2424.  
  2425.         END;  { ODP^.Name^ }
  2426.  
  2427.       END;  { ODF_DriverOn }
  2428.  
  2429.       {----}
  2430.  
  2431.       ODF_DriverDispose:
  2432.       BEGIN
  2433.  
  2434.         If ODP^.Name^ = IData^.Name Then
  2435.         BEGIN
  2436.  
  2437.           {RemoveFromOutDriverStack }
  2438.  
  2439.           Dispose( IData );
  2440.  
  2441.         END;  { If ODP^.Name^ }
  2442.  
  2443.       END;  { ODF_DriverDispose }
  2444.  
  2445.       {----}
  2446.  
  2447.  
  2448.       ODF_WriteVert:
  2449.       BEGIN
  2450.  
  2451.         With AS^ DO
  2452.         BEGIN
  2453.  
  2454.           For Z:=1 to ODP^.Size Do
  2455.           BEGIN
  2456.  
  2457.             S^[ (CurY*YMult)+CurX ].Char := PCharBuff( ODP^.Buff )^[Z];
  2458.             S^[ (CurY*YMult)+CurX ].Attr := CurAttr;
  2459.  
  2460.             CursorDown( TRUE );
  2461.  
  2462.           END;  { For Z }
  2463.  
  2464.         END; { With AS^ }
  2465.  
  2466.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  2467.  
  2468.       END;  { ODF_WriteVert }
  2469.  
  2470.       {----}
  2471.  
  2472.       ODF_WriteCharAt:
  2473.       BEGIN
  2474.  
  2475.         With AS^ Do
  2476.         BEGIN
  2477.  
  2478.           S^[ (Pred(ODP^.Y1)*YMult)+Pred(ODP^.X1) ].Char := ODP^.CH;
  2479.  
  2480.           S^[ (Pred(ODP^.Y1)*YMult)+Pred(ODP^.X1) ].Attr :=
  2481.                                             CRTColorMap[ ODP^.Attr ];
  2482.  
  2483.         END; { With AS^ }
  2484.  
  2485.  
  2486.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  2487.  
  2488.  
  2489.       END;  { ODF_WriteCharAt }
  2490.  
  2491.       {----}
  2492.  
  2493.       ODF_WriteBlockAt:
  2494.       BEGIN
  2495.  
  2496.         With AS^ DO
  2497.         BEGIN
  2498.  
  2499.           SaveCurX := CurX;
  2500.           SaveCurY := CurY;
  2501.  
  2502.           For Z:=1 to ODP^.Size Do
  2503.           BEGIN
  2504.  
  2505.             S^[ (Pred(ODP^.Y1)*YMult)+ODP^.X1+Z-2].Char :=
  2506.                                         PCharBuff( ODP^.Buff )^[Z];
  2507.  
  2508.             S^[ (Pred(ODP^.Y1)*YMult)+ODP^.X1+Z-2].Attr :=
  2509.                                             CRTColorMap[ ODP^.Attr ];
  2510.  
  2511.           END; { For Z }
  2512.  
  2513.         END; { With AS^ }
  2514.  
  2515.  
  2516.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  2517.  
  2518.       END;  { ODF_WriteBlockAt }
  2519.  
  2520.       {----}
  2521.  
  2522.       ODF_WriteVertAt:
  2523.       BEGIN
  2524.  
  2525.         With AS^ DO
  2526.         BEGIN
  2527.  
  2528.           For Z:=1 to ODP^.Size Do
  2529.           BEGIN
  2530.  
  2531.             S^[ ((ODP^.Y1+Z-2)*YMult)+Pred(ODP^.X1) ].Char :=
  2532.                                         PCharBuff( ODP^.Buff )^[Z];
  2533.  
  2534.             S^[ ((ODP^.Y1+Z-2)*YMult)+Pred(ODP^.X1) ].Attr :=
  2535.                                         CRTColorMap[ ODP^.Attr ];
  2536.  
  2537.           END;  { For Z }
  2538.  
  2539.         END; { With AS^ }
  2540.  
  2541.  
  2542.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  2543.  
  2544.       END;  { ODF_WriteVertAt }
  2545.  
  2546.       {----}
  2547.  
  2548.       ODF_ClrEOL:
  2549.       BEGIN
  2550.  
  2551.         With AS^ DO
  2552.         BEGIN
  2553.  
  2554.           For Z:=CurX to WinX2 Do
  2555.           BEGIN
  2556.  
  2557.             S^[ (CurY*YMult)+Z ].Char := ' ';
  2558.             S^[ (CurY*YMult)+Z ].Attr := CurAttr;
  2559.  
  2560.           END;  { For Z }
  2561.  
  2562.           { Cursor to next line? }
  2563.  
  2564.         END; { With AS^ }
  2565.  
  2566.  
  2567.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  2568.  
  2569.  
  2570.       END;  { ODF_ClrEOL }
  2571.  
  2572.       {----}
  2573.  
  2574.       ODF_ClrScr:
  2575.       BEGIN
  2576.  
  2577.         MyClrScr;
  2578.  
  2579.       END;  { ODF_ClrScr }
  2580.  
  2581.       {----}
  2582.  
  2583.       ODF_DelLine:
  2584.       BEGIN
  2585.  
  2586.         With AS^ Do
  2587.         BEGIN
  2588.  
  2589.           RegionScroll( WinX1,
  2590.                         CurY,
  2591.                         WinX2,
  2592.                         WinY2,
  2593.                         -1         );
  2594.  
  2595.           { Cursor to WinX1?? }
  2596.  
  2597.         END;  { With AS^ }
  2598.  
  2599.  
  2600.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  2601.  
  2602.  
  2603.       END;  { ODF_DelLine }
  2604.  
  2605.       {----}
  2606.  
  2607.       ODF_InsLine:
  2608.       BEGIN
  2609.  
  2610.         With AS^ Do
  2611.         BEGIN
  2612.  
  2613.           RegionScroll( WinX1,
  2614.                         CurY,
  2615.                         WinX2,
  2616.                         WinY2,
  2617.                         1         );
  2618.  
  2619.           { Cursor to WinX1?? }
  2620.  
  2621.         END;  { With AS^ }
  2622.  
  2623.  
  2624.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  2625.  
  2626.  
  2627.       END;  { ODF_InsLine }
  2628.  
  2629.       {----}
  2630.  
  2631.       ODF_GotoXY:
  2632.       BEGIN
  2633.  
  2634.         With AS^Do
  2635.         BEGIN
  2636.  
  2637.           CurX := WinX1+(ODP^.X1-1);
  2638.           CurY := WinY1+(ODP^.Y1-1);
  2639.  
  2640.           If (IData^.VirtualCRT=FALSE) Then
  2641.             RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  2642.  
  2643.         END;  { With AS^ }
  2644.  
  2645.       END;  { ODF_GotoXY }
  2646.  
  2647.       {----}
  2648.  
  2649.       ODF_Window:
  2650.       BEGIN
  2651.  
  2652.         With AS^ Do
  2653.         BEGIN
  2654.  
  2655.           WinX1 := ODP^.X1-1;
  2656.           WinY1 := ODP^.Y1-1;
  2657.           WinX2 := ODP^.X2-1;
  2658.           WinY2 := ODP^.Y2-1;
  2659.  
  2660.           If WinX2<WinX1 Then SwapCoords( WinX1, WinX2 );
  2661.           If WinY2<WinY1 Then SwapCoords( WinY1, WinY2 );
  2662.  
  2663.           CurX  := WinX1;
  2664.           CurY  := WinY1;
  2665.  
  2666.           If (IData^.VirtualCRT=FALSE) Then
  2667.             RealCursorGoto( IData^.Ascreen-1, CurX, Cury );
  2668.  
  2669.           { call visionix services to set window coords }
  2670.  
  2671.         END;  { With AS^ }
  2672.  
  2673.       END;  { ODF_Window }
  2674.  
  2675.       {----}
  2676.  
  2677.       { 7 6 5 4 3 2 1 0 }
  2678.       { F B B B T T T T }
  2679.  
  2680.       ODF_ColorText:
  2681.       BEGIN
  2682.  
  2683.         With AS^ Do
  2684.         BEGIN
  2685.  
  2686.           CurAttr := (CurAttr AND $F0) + (ODP^.TheColor AND $0F);
  2687.  
  2688.         END;  { With AS^ }
  2689.  
  2690.       END;  { ODF_ColorText }
  2691.  
  2692.       {----}
  2693.  
  2694.       ODF_ColorBack:
  2695.       BEGIN
  2696.  
  2697.         With AS^ Do
  2698.         BEGIN
  2699.  
  2700.           CurAttr := (CurAttr AND $0F) + ((ODP^.TheColor AND $07) SHL 4);
  2701.  
  2702.         END;  { With AS^ }
  2703.  
  2704.       END;  { ODF_ColorBack }
  2705.  
  2706.       {----}
  2707.  
  2708.       ODF_GetWin:
  2709.       BEGIN
  2710.  
  2711.         With AS^ Do
  2712.         BEGIN
  2713.  
  2714.           ODP^.X1 := WinX1+1;
  2715.           ODP^.Y1 := WinY1+1;
  2716.           ODP^.X2 := WinX2+1;
  2717.           ODP^.Y2 := WinY2+1;
  2718.  
  2719.           ODP^.Status := ODS_Changed;
  2720.  
  2721.         END;  { With AS^ }
  2722.  
  2723.       END;  { ODF_GetWin }
  2724.  
  2725.       {----}
  2726.  
  2727.       ODF_GetAttr:
  2728.       BEGIN
  2729.  
  2730.         ODP^.Attr   := AS^.CurAttr;
  2731.  
  2732.         ODP^.Status := ODS_Changed;
  2733.  
  2734.       END;  { ODF_GetAttr }
  2735.  
  2736.       {----}
  2737.  
  2738.       ODF_SetAttr:
  2739.       BEGIN
  2740.  
  2741.         AS^.CurAttr := ODP^.Attr;
  2742.  
  2743.       END;  { ODF_SetAttr }
  2744.  
  2745.       {----}
  2746.  
  2747.       ODF_GetXY:
  2748.       BEGIN
  2749.  
  2750.         ODP^.X1 := (AS^.CurX+1)-AS^.WinX1;
  2751.         ODP^.Y1 := (AS^.CurY+1)-AS^.WinY1;
  2752.  
  2753.         ODP^.Status := ODS_Changed;
  2754.  
  2755.       END;  { ODF_GetXY }
  2756.  
  2757.       {----}
  2758.  
  2759.       ODF_GetNumScreens:
  2760.       BEGIN
  2761.  
  2762.         ODP^.Screens := IData^.NumScreens;
  2763.  
  2764.         ODP^.Status  := ODS_Changed;
  2765.  
  2766.       END;  { ODF_GetNumScreens }
  2767.  
  2768.       {----}
  2769.  
  2770.       ODF_GoScreen:
  2771.       BEGIN
  2772.  
  2773.         If ODP^.Screens <= IData^.NumScreens Then
  2774.           IData^.AScreen := ODP^.Screens;
  2775.  
  2776.       END;  { ODF_GoScreen }
  2777.  
  2778.       {----}
  2779.  
  2780.       ODF_SetCursorType:
  2781.       BEGIN
  2782.  
  2783.         MySetCursorType( ODP^.NumVal );
  2784.  
  2785.         AS^.CurType := ODP^.NumVal;
  2786.  
  2787.       END;  { ODF_SetCursorType }
  2788.  
  2789.       {----}
  2790.  
  2791.  
  2792.       ODF_DrawVLine:
  2793.       BEGIN
  2794.  
  2795.       END;  { ODF_DrawVLine }
  2796.  
  2797.       {----}
  2798.  
  2799.       ODF_DrawHLine:
  2800.       BEGIN
  2801.  
  2802.       END;  { ODF_DrawHLine }
  2803.  
  2804.       {----}
  2805.  
  2806.       ODF_DrawBox:
  2807.       BEGIN
  2808.  
  2809.       END;  { ODF_DrawBox }
  2810.  
  2811.       {----}
  2812.  
  2813.       ODF_ReadChar:
  2814.       BEGIN
  2815.  
  2816.         ODP^.CH := AS^.S^[ (Pred(ODP^.Y1)*YMult)+Pred(ODP^.X1) ].Char;
  2817.  
  2818.         ODP^.Status := ODS_Changed;
  2819.  
  2820.       END;  { ODF_ReadChar }
  2821.  
  2822.       {----}
  2823.  
  2824.       ODF_ReadAttr:
  2825.       BEGIN
  2826.  
  2827.         ODP^.Attr := AS^.S^[ (Pred(ODP^.Y1)*YMult)+ODP^.X1-1 ].Attr;
  2828.  
  2829.         ODP^.Status := ODS_Changed;
  2830.  
  2831.       END;  { ODF_ReadAttr }
  2832.  
  2833.       {----}
  2834.  
  2835.       ODF_WriteAttr:
  2836.       BEGIN
  2837.  
  2838.         AS^.S^[ (Pred(ODP^.Y1)*YMult)+ODP^.X1-1 ].Attr :=
  2839.                                              CRTColorMap[ ODP^.Attr ];
  2840.  
  2841.  
  2842.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  2843.  
  2844.  
  2845.       END;  { ODF_WriteAttr }
  2846.  
  2847.       {----}
  2848.  
  2849.  
  2850.       ODF_QueryRegion:
  2851.       BEGIN
  2852.  
  2853.         ODP^.RegionSize := ((ODP^.Y2-ODP^.Y1)+1)*((ODP^.X2-ODP^.X1)+1)*2;
  2854.  
  2855.         ODP^.Status := ODS_Changed;
  2856.  
  2857.       END;  { ODF_QueryRegion }
  2858.  
  2859.       {----}
  2860.  
  2861.  
  2862.       ODF_ReadRegion:
  2863.       BEGIN
  2864.  
  2865.         If ODP^.Status AND ODS_Changed=0 Then
  2866.  
  2867.           RegionRead( Pred(ODP^.X1), Pred(ODP^.Y1),
  2868.                       Pred(ODP^.X2), Pred(ODP^.Y2), ODP^.Region );
  2869.  
  2870.         ODP^.Status := ODS_Changed;
  2871.  
  2872.  
  2873.       END;  { ODF_ReadRegion }
  2874.  
  2875.       {----}
  2876.  
  2877.       ODF_WriteRegion:
  2878.       BEGIN
  2879.  
  2880.         RegionWrite( ODP^.X1-1, ODP^.Y1-1,
  2881.                      ODP^.X2-1, ODP^.Y2-1, ODP^.Region );
  2882.  
  2883.  
  2884.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  2885.  
  2886.  
  2887.       END;  { ODF_WriteRegion }
  2888.  
  2889.       {----}
  2890.  
  2891.  
  2892.       ODF_DriverRenew:
  2893.       BEGIN
  2894.  
  2895.       END;  { ODF_DriverRenew }
  2896.  
  2897.       {----}
  2898.  
  2899.       ODF_CursorUp:
  2900.       BEGIN
  2901.  
  2902.         With AS^Do
  2903.         BEGIN
  2904. (*
  2905.           If (CurY-ODP^.Numval) >= WinY1 Then
  2906.             Dec( CurY, ODP^.NumVal )
  2907.           Else
  2908.             CurY := WinY1;
  2909. *)
  2910.  
  2911.           For Z:=1 to ODP^.NumVal Do
  2912.             If CurY>WinY1 Then
  2913.               Dec(CurY);
  2914.  
  2915.  
  2916.           If (IData^.VirtualCRT=FALSE) Then
  2917.             RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  2918.  
  2919.         END;  { With AS^ }
  2920.  
  2921.       END;  { ODF_CursorUp }
  2922.  
  2923.      {----}
  2924.  
  2925.       ODF_CursorDown:
  2926.       BEGIN
  2927.  
  2928.         With AS^Do
  2929.         BEGIN
  2930. (*
  2931.           If (CurY+ODP^.Numval) <= WinY2 Then
  2932.             Inc( CurY, ODP^.NumVal )
  2933.           Else
  2934.             CurY := WinY2;
  2935. *)
  2936.           For Z:=1 to ODP^.NumVal Do
  2937.             If CurY<WinY2 Then
  2938.               Inc(CurY);
  2939.  
  2940.           If (IData^.VirtualCRT=FALSE) Then
  2941.             RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  2942.  
  2943.         END;  { With AS^ }
  2944.  
  2945.       END;  { ODF_CursorDown }
  2946.  
  2947.     {----}
  2948.  
  2949.       ODF_CursorLeft:
  2950.       BEGIN
  2951.  
  2952.         With AS^ Do
  2953.         BEGIN
  2954. (*
  2955.           If (CurX-ODP^.Numval) >= WinX1 Then
  2956.             Dec( CurY, ODP^.NumVal )
  2957.           Else
  2958.             CurX := WinX1;
  2959. *)
  2960.  
  2961.           For Z:=1 to ODP^.Numval Do
  2962.             If CurX>WinX1 Then
  2963.               Dec(CurX);
  2964.  
  2965.  
  2966.           If (IData^.VirtualCRT=FALSE) Then
  2967.             RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  2968.  
  2969.         END;  { With AS^ }
  2970.  
  2971.       END;  { ODF_CursorLeft }
  2972.  
  2973.      {----}
  2974.  
  2975.       ODF_CursorRight:
  2976.       BEGIN
  2977.  
  2978.         With AS^Do
  2979.         BEGIN
  2980. (*
  2981.           If (CurX+ODP^.NumVal) <= WinX2 Then
  2982.             Inc( CurX, ODP^.NumVal )
  2983.           Else
  2984.             CurY := WinX2;
  2985. *)
  2986.           For Z:=1 to ODP^.Numval Do
  2987.             If CurX<WinX2 Then
  2988.               Inc(CurX);
  2989.  
  2990.  
  2991.           If (IData^.VirtualCRT=FALSE) Then
  2992.             RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  2993.  
  2994.         END;  { With AS^ }
  2995.  
  2996.       END;  { ODF_CursorRight }
  2997.  
  2998.      {----}
  2999.  
  3000.       ODF_RegionScrUp:
  3001.       BEGIN
  3002.  
  3003.         RegionScroll( Pred(ODP^.X1), Pred(ODP^.Y1),
  3004.                       Pred(ODP^.X2), Pred(ODP^.Y2),
  3005.                       0-ODP^.NumVal         );
  3006.  
  3007.  
  3008.  
  3009.       END;  { ODF_RegionScrUp }
  3010.  
  3011.      {----}
  3012.  
  3013.       ODF_RegionScrDown:
  3014.       BEGIN
  3015.  
  3016.  
  3017.         RegionScroll( Pred(ODP^.X1), Pred(ODP^.Y1),
  3018.                       Pred(ODP^.X2), Pred(ODP^.Y2),
  3019.                       ODP^.NumVal         );
  3020.  
  3021.       END;  { ODF_RegionScrDown }
  3022.  
  3023.      {----}
  3024.  
  3025.       ODF_RegionCopy:
  3026.       BEGIN
  3027.  
  3028.       END;  { ODF_RegionCopy }
  3029.  
  3030.      {----}
  3031.  
  3032.       ODF_RegionFill:
  3033.       BEGIN
  3034.  
  3035.         With AS^ DO
  3036.         BEGIN
  3037.  
  3038.           For Z2:=Pred(ODP^.Y1) to Pred(ODP^.Y2) Do
  3039.           BEGIN
  3040.  
  3041.             For Z:=Pred(ODP^.X1) to Pred(ODP^.X2) Do
  3042.             BEGIN
  3043.  
  3044.               S^[ (Z2*YMult)+Z ].Char := ODP^.CH;
  3045.               S^[ (Z2*YMult)+Z ].Attr := ODP^.Attr;
  3046.  
  3047.             END; { For Z (x) }
  3048.  
  3049.           END; { For Z2 (y) }
  3050.  
  3051.         END; { With AS^ }
  3052.  
  3053.  
  3054.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  3055.  
  3056.  
  3057.       END;  { ODF_RegionFill }
  3058.  
  3059.      {----}
  3060.  
  3061.       ODF_RegionFillA:
  3062.       BEGIN
  3063.  
  3064.         With AS^ DO
  3065.         BEGIN
  3066.  
  3067.           For Z2:=Pred(ODP^.Y1) to Pred(ODP^.Y2) Do
  3068.           BEGIN
  3069.  
  3070.             For Z:=Pred(ODP^.X1) to Pred(ODP^.X2) Do
  3071.             BEGIN
  3072.  
  3073.               S^[ (Z2*YMult)+Z ].Attr := ODP^.Attr;
  3074.  
  3075.             END; { For Z (x) }
  3076.  
  3077.           END; { For Z2 (y) }
  3078.  
  3079.         END; { With AS^ }
  3080.  
  3081.  
  3082.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  3083.  
  3084.       END;  { ODF_RegionFillA }
  3085.  
  3086.      {----}
  3087.  
  3088.       ODF_RegionFillC:
  3089.       BEGIN
  3090.  
  3091.         With AS^ DO
  3092.         BEGIN
  3093.  
  3094.           For Z2:=Pred(ODP^.Y1) to Pred(ODP^.Y2) Do
  3095.           BEGIN
  3096.  
  3097.             For Z:=Pred(ODP^.X1) to Pred(ODP^.X2) Do
  3098.             BEGIN
  3099.  
  3100.               S^[ (Z2*YMult)+Z ].Char := ODP^.CH;
  3101.  
  3102.             END; { For Z (x) }
  3103.  
  3104.           END; { For Z2 (y) }
  3105.  
  3106.         END; { With AS^ }
  3107.  
  3108.  
  3109.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  3110.  
  3111.       END;  { ODF_RegionFillC }
  3112.  
  3113.      {----}
  3114.  
  3115.       ODF_RepeatChar:
  3116.       BEGIN
  3117.  
  3118.         With AS^ Do
  3119.         BEGIN
  3120.  
  3121.           IF (ODP^.CH<>#13) and (ODP^.CH<>#10) Then
  3122.           BEGIN
  3123.  
  3124.             For Z:=1 to ODP^.NumVal Do
  3125.             BEGIN
  3126.  
  3127.               S^[ (CurY*YMult)+CurX ].Char := ODP^.CH;
  3128.               S^[ (CurY*YMult)+CurX ].Attr := CurAttr;
  3129.  
  3130.               CursorNextChar( FALSE );
  3131.  
  3132.             END;  { For Z }
  3133.  
  3134.             If (IData^.VirtualCRT=FALSE) Then
  3135.               RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  3136.  
  3137.           END;  { If ODP^.Ch }
  3138.  
  3139.         END; { With AS^ }
  3140.  
  3141.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  3142.  
  3143.       END;  { ODF_RepeatChar }
  3144.  
  3145.      {----}
  3146.  
  3147.       ODF_RepeatCharAt:
  3148.       BEGIN
  3149.  
  3150.         With AS^ DO
  3151.         BEGIN
  3152.  
  3153.           SaveCurX := CurX;
  3154.           SaveCurY := CurY;
  3155.  
  3156.           For Z:=1 to ODP^.NumVal Do
  3157.           BEGIN
  3158.  
  3159.             S^[ (Pred(ODP^.Y1)*YMult)+ODP^.X1+Z-2].Char := ODP^.CH;
  3160.  
  3161.             S^[ (Pred(ODP^.Y1)*YMult)+ODP^.X1+Z-2].Attr :=
  3162.                                             CRTColorMap[ ODP^.Attr ];
  3163.  
  3164.           END; { For Z }
  3165.  
  3166.         END; { With AS^ }
  3167.  
  3168.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  3169.  
  3170.       END;  { ODF_RepeatCharAt }
  3171.  
  3172.      {----}
  3173.  
  3174.       ODF_GetScreenSize:
  3175.       BEGIN
  3176.  
  3177.         With AS^ Do
  3178.         BEGIN
  3179.  
  3180.           ODP^.X1 := IData^.Cols;
  3181.           ODP^.Y1 := Idata^.Rows;
  3182.  
  3183.         END;  { With AS^ }
  3184.  
  3185.       END;  { ODF_GetScreenSize }
  3186.  
  3187.      {----}
  3188.  
  3189.      ODF_RepeatBlock:
  3190.      BEGIN
  3191.  
  3192.         With AS^ DO
  3193.         BEGIN
  3194.  
  3195.           Z3 := ODP^.Start;
  3196.  
  3197.           For Z2:=1 to ODP^.NumVal Do
  3198.           BEGIN
  3199.  
  3200.             For Z:=Z3 to ODP^.Size Do
  3201.             BEGIN
  3202.  
  3203.               Case PCharBuff( ODP^.Buff)^[Z] Of
  3204.  
  3205.                 #13:
  3206.                 BEGIN
  3207.  
  3208.                   CurX := WinX1;
  3209.  
  3210.                   RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  3211.  
  3212.                 END;  { #13 }
  3213.  
  3214.                 #10:
  3215.                 BEGIN
  3216.  
  3217.                   CursorDown( TRUE );
  3218.  
  3219.                 END;
  3220.  
  3221.               Else
  3222.  
  3223.                 S^[ (CurY*YMult)+CurX ].Char := PCharBuff( ODP^.Buff )^[Z];
  3224.                 S^[ (CurY*YMult)+CurX ].Attr := CurAttr;
  3225.  
  3226.                 CursorNextChar( FALSE );
  3227.  
  3228.               END;  { Case PCharBuff( ODP^.Buf)^[Z] }
  3229.  
  3230.             END; { For Z }
  3231.  
  3232.             Z3 := 1;
  3233.  
  3234.           END; { for Z2 }
  3235.  
  3236.           RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  3237.  
  3238.         END; { With AS^ }
  3239.  
  3240.         ODP^.Start := ODP^.Size;
  3241.  
  3242.  
  3243.         {$IFDEF OS2} SyncScreen; {$ENDIF}
  3244.  
  3245.      END; { ODF_Repeatblock }
  3246.  
  3247.  
  3248.  
  3249.      {----}
  3250.      {----}
  3251.  
  3252.     Else { Else Case }
  3253.  
  3254.     END;  { Case ODP^.Func }
  3255.  
  3256.   END; { If ODP^.Status = 0 }
  3257.  
  3258.   CallNextDriver( ODP );
  3259.  
  3260. END;  { CRTOutDriverProc }
  3261.  
  3262. {────────────────────────────────────────────────────────────────────────────}
  3263.  
  3264. {$IFDEF OS2}
  3265.  
  3266. Procedure VIOOutDriverProc(       ODP            : POutDriverPacket );
  3267.  
  3268. Type
  3269.  
  3270.   TCharBuff = Array[1..32768] of CHAR;
  3271.   PCharBuff = ^TCharBuff;
  3272.  
  3273.   {----}
  3274.  
  3275.   TCell = Record
  3276.  
  3277.     Char    : CHAR;
  3278.     Attr    : BYTE;
  3279.  
  3280.   END;  { TCell }
  3281.  
  3282.   {----}
  3283.  
  3284.   TScreenStore = Array[0..32000] of TCell;
  3285.  
  3286.   PScreenStore = ^TScreenStore;
  3287.  
  3288.   {----}
  3289.  
  3290.   TScreen = RECORD
  3291.  
  3292.     CurX      : WORD;
  3293.     CurY      : WORD;
  3294.     CurAttr   : BYTE;
  3295.  
  3296.     WinX1     : WORD;
  3297.     WinX2     : WORD;
  3298.     WinY1     : WORD;
  3299.     WinY2     : WORD;
  3300.  
  3301.     CurType   : WORD;
  3302.  
  3303.     ScreenSize: WORD;
  3304.  
  3305.     S         : PScreenStore;
  3306.  
  3307.   END;  { TScreen }
  3308.  
  3309.   PScreen = ^TScreen;
  3310.  
  3311.   {----}
  3312.  
  3313.   TVIOOutDriverIData = Record
  3314.  
  3315.     Off        : WORD;
  3316.     Name       : TProcName;
  3317.  
  3318.     VirtualCRT : BOOLEAN;
  3319.  
  3320.     DisplayMode: BYTE;
  3321.  
  3322.     Cols       : WORD;
  3323.     Rows       : WORD;
  3324.  
  3325.     YMult      : WORD;
  3326.  
  3327.     NumScreens : BYTE;
  3328.  
  3329.     AScreen    : BYTE;
  3330.  
  3331.     Screen     : Array[1..8] of TScreen;
  3332.  
  3333.     MyODP      : TOutDriverPacket;
  3334.  
  3335.   END;  { TVIOOutDriverIData }
  3336.  
  3337.   PVIOOutDriverIData = ^TVIOOutDriverIData;
  3338.  
  3339.   {----}
  3340.  
  3341.   TVCRTDriverInfo = RECORD
  3342.  
  3343.     Cols    : WORD;
  3344.     Rows    : WORD;
  3345.     Screens : WORD;
  3346.  
  3347.   END;  { TVCRTDriverInfo }
  3348.  
  3349.   PVCRTDriverInfo = ^TVCRTDriverInfo;
  3350.  
  3351.   MyPByte = ^Byte;
  3352.   MyPWord = ^Word;
  3353.  
  3354. Var
  3355.  
  3356.   IData      : PVIOOutDriverIData;
  3357.   YMult      : WORD;
  3358.  
  3359.   AS         : PScreen;
  3360.  
  3361.   Z          : INTEGER;
  3362.   Z2         : INTEGER;
  3363.   Z3         : INTEGER;
  3364.  
  3365.   TheCell    : TCell;
  3366.  
  3367.   SaveCurX   : WORD;
  3368.   SaveCurY   : WORD;
  3369.  
  3370.   CallNext   : BOOLEAN;
  3371.  
  3372.   {────────────────────────────────────────────────────────────────────────}
  3373.  
  3374.   Procedure InitVIOIdata;
  3375.  
  3376.   Type
  3377.     MyPtrWord = ^WORD;
  3378.  
  3379.   Var
  3380.  
  3381.   {$IFNDEF OS2}
  3382.     R        : REGISTERS;
  3383.   {$ENDIF}
  3384.     Z        : INTEGER;
  3385.     StoreOfs : WORD;
  3386.  
  3387.     VMI      : TVIOModeInfo;
  3388.  
  3389.   BEGIN
  3390.  
  3391.  
  3392.     {---------------------------------------}
  3393.     { Determine CRT type; mono, hercules-1, }
  3394.     { hercules-2, hercules in-color, cga,   }
  3395.     { ega, or vga                           }
  3396.     {---------------------------------------}
  3397.  
  3398.     {$IFDEF DEBUG}
  3399.       DebugWrite('VioGetMode...');
  3400.     {$ENDIF}
  3401.  
  3402.     VMI.CB := 12;  { have to setup byte count of record first }
  3403.  
  3404.     VioGetMode( VMI, 0 );
  3405.  
  3406.  
  3407.     {$IFDEF DEBUG }
  3408.       Write( DebugFile, 'DONE.');
  3409.       WriteLN( DebugFile, '  Cols=',vmi.cols,' Rows=',vmi.rows );
  3410.     {$ENDIF}
  3411.  
  3412.  
  3413.  
  3414.     IData^.DisplayMode := 3;
  3415.     IData^.AScreen     := 1;
  3416.     IData^.Cols        := VMI.Cols;
  3417.     IData^.Rows        := VMI.Rows;
  3418.     IData^.YMult       := IData^.Cols;
  3419.  
  3420.     {------------------------------}
  3421.     { Determine # of screens/pages }
  3422.     {------------------------------}
  3423.  
  3424.     IData^.NumScreens := 1;
  3425.  
  3426.     {------------------------------}
  3427.     { Determine if Font8x8 is used }
  3428.     {------------------------------}
  3429.  
  3430.     { If Vga and rows=50 then yes }
  3431.  
  3432.     { If Ega and rows=43 then yes }
  3433.  
  3434.     {-----------------------}
  3435.     { Get information       }
  3436.     { For each display page }
  3437.     {-----------------------}
  3438.  
  3439.     For Z:= 1 to IData^.NumScreens Do
  3440.     BEGIN
  3441.  
  3442.       {--------------------}
  3443.       { Get cursor X and Y }
  3444.       {--------------------}
  3445.  
  3446.       {$IFDEF DEBUG}
  3447.       DebugWrite('VioGetCurPos...');
  3448.       {$ENDIF}
  3449.  
  3450.       VioGetCurPos( IData^.Screen[Z].CurY,
  3451.                     IData^.Screen[Z].CurX,
  3452.                     0                           );
  3453.  
  3454.       {$IFDEF DEBUG}
  3455.         WriteLN( DebugFile, 'DONE.  CurX=',IData^.Screen[Z].CurX,
  3456.                                   ' CurY=',IData^.Screen[Z].CurY   );
  3457.       {$ENDIF}
  3458.  
  3459.  
  3460.  
  3461.       idata^.screen[z].cury := 0;
  3462.       idata^.screen[z].curx := 0;
  3463.  
  3464.       {-----------------}
  3465.       { Get cursor type }
  3466.       {-----------------}
  3467.  
  3468.       { set it and sync the crt }
  3469.  
  3470.       {-----------------------}
  3471.       { Get Current Attribute }
  3472.       {-----------------------}
  3473.  
  3474.       IData^.Screen[Z].CurAttr := 7;
  3475.  
  3476.       {--------------------}
  3477.       { Init window coords }
  3478.       {--------------------}
  3479.  
  3480.       { call visionix services to determine window coords }
  3481.  
  3482.       IData^.Screen[Z].WinX1 := 0;
  3483.       IData^.Screen[Z].WinY1 := 0;
  3484.       IData^.Screen[Z].WinX2 := IData^.Cols-1;
  3485.       IData^.Screen[Z].WinY2 := IData^.Rows-1;
  3486.  
  3487.       {----------------------------}
  3488.       { Get Pointer to screen/page }
  3489.       {----------------------------}
  3490.  
  3491.       IData^.Screen[Z].S     := NIL;
  3492.  
  3493.       { we can't get the pointers to each page }
  3494.       { until we switch to the page.  we can,  }
  3495.       { however, get the pointer to the active }
  3496.       { page, which we will do later.          }
  3497.  
  3498.  
  3499.     END; { For Z := 1 to numscreens/pages }
  3500.  
  3501.  
  3502.     {---------------------------------}
  3503.     { get a pointer to the vid buffer }
  3504.     {---------------------------------}
  3505.  
  3506.     {$IFDEF DEBUG}
  3507.       DebugWrite('VioGetBuf...');
  3508.     {$ENDIF}
  3509.  
  3510.     VioGetBuf( Pointer(IData^.Screen[ 1 ].S),
  3511.                IData^.Screen[1].ScreenSize, 0 );
  3512.  
  3513.     {$IFDEF DEBUG}
  3514.       DebugWriteLn('DONE.');
  3515.     {$ENDIF}
  3516.  
  3517.   END; { InitCRTIData }
  3518.  
  3519.   {────────────────────────────────────────────────────────────────────────}
  3520.  
  3521.   Procedure SyncScreen;
  3522.  
  3523.   BEGIN
  3524.  
  3525.     VioShowBuf( 0, AS^.ScreenSize, 0 );
  3526.  
  3527.   END;
  3528.  
  3529.   {---------}
  3530.  
  3531.   Procedure RegionScroll(         X1,Y1,X2,Y2    : WORD;
  3532.                                   Count          : INTEGER   );
  3533.  
  3534.   Var
  3535.  
  3536.     NC : TCell;
  3537.  
  3538.   BEGIN
  3539.  
  3540.     {  x/y coords come in relative to zero }
  3541.  
  3542.     NC.Char := ' ';
  3543.     NC.Attr := AS^.CurAttr;
  3544.  
  3545.     If Count<0 Then
  3546.     BEGIN
  3547.  
  3548.       { scroll up }
  3549.  
  3550.  
  3551.       VioScrollUp( Y1,X1,
  3552.                    Y2,X2,
  3553.                    Abs( Count ),
  3554.                    @NC,
  3555.                    0                );
  3556.  
  3557.     END
  3558.     ELSE
  3559.     BEGIN
  3560.  
  3561.       { scroll down/back }
  3562.  
  3563.       VioScrollDn( Y1,X1,
  3564.                    Y2,X2,
  3565.                    Count,
  3566.                    @NC,
  3567.                    0                );
  3568.  
  3569.  
  3570.     END;
  3571.  
  3572.   END;
  3573.  
  3574.   {────────────────────────────────────────────────────────────────────────}
  3575.  
  3576. (*-
  3577.  
  3578. [FUNCTION]
  3579.  
  3580. Procedure RegionRead(             X1,Y1,X2,Y2    : WORD;
  3581.                                   Region         : PScreenStore );
  3582.  
  3583. [PARAMETERS]
  3584.  
  3585. X1          Source Left Screen Region Coordinate
  3586. Y1          Source Top Screen Region Coordinate
  3587. X2          Source Right Region Screen Region Coordinate
  3588. Y2          Source Bottom Screen Region Coordinate
  3589. Region      Pointer to Region Read Data
  3590.  
  3591. [RETURNS]
  3592.  
  3593. (None)
  3594.  
  3595. [DESCRIPTION]
  3596.  
  3597. Reads a region from the display console to a region store buffer.
  3598. "Region" should be a pointer to a buffer which is big enough to hold
  3599. the region data.  Use RegionMemQuery to determine how many bytes must
  3600. be allocated.
  3601.  
  3602. [SEE-ALSO]
  3603.  
  3604. [EXAMPLE]
  3605.  
  3606. -*)
  3607.  
  3608.   Procedure RegionRead(           X1,Y1,X2,Y2    : WORD;
  3609.                                   Region         : PScreenStore );
  3610.   Var
  3611.     Wid  : WORD;
  3612.     Wid2 : WORD;
  3613.     Z    : INTEGER;
  3614.  
  3615.   BEGIN
  3616.  
  3617.     { x/y coords come in relative to zero }
  3618.  
  3619.     Wid  := (X2-X1)+1;
  3620.  
  3621.     For Z:= Y1 To Y2 Do
  3622.     BEGIN
  3623.  
  3624.       Wid2 := Wid*2;
  3625.  
  3626.       VioReadCellStr(  @Region^[ (Z-Y1)*Wid ],
  3627.                        Wid2,
  3628.                         Z  ,
  3629.                         X1 ,
  3630.                        0                           );
  3631.  
  3632.     END;  { For Z }
  3633.  
  3634.   END;  { RegionRead }
  3635.  
  3636.   {────────────────────────────────────────────────────────────────────────}
  3637.  
  3638. (*-
  3639.  
  3640. [FUNCTION]
  3641.  
  3642. Procedure RegionWrite(            X1,Y1,X2,Y2    : WORD;
  3643.                                   Region         : PScreenStore );
  3644.  
  3645. [PARAMETERS]
  3646.  
  3647. X1          Left Screen Region Coordinate
  3648. Y1          Top Screen Region Coordinate
  3649. X2          Right Region Screen Region Coordinate
  3650. Y2          Bottom Screen Region Coordinate
  3651. Region      Pointer to Region Write Data
  3652.  
  3653. [RETURNS]
  3654.  
  3655. (None)
  3656.  
  3657. [DESCRIPTION]
  3658.  
  3659. [SEE-ALSO]
  3660.  
  3661. [EXAMPLE]
  3662.  
  3663. -*)
  3664.  
  3665.   Procedure RegionWrite(          X1,Y1,X2,Y2    : WORD;
  3666.                                   Region         : PScreenStore );
  3667.  
  3668.   Var
  3669.     Wid  : WORD;
  3670.     Wid2 : WORD;
  3671.     Z    : INTEGER;
  3672.  
  3673.   BEGIN
  3674.  
  3675.     { x/y coords come in relative to 0 }
  3676.  
  3677.     Wid  := (X2-X1)+1;
  3678.     Wid2 := Wid*2;
  3679.  
  3680.     For Z:= Y1 To Y2 Do
  3681.     BEGIN
  3682.  
  3683.       VioWrtCellStr( @Region^[ (Z-Y1)*Wid ],
  3684.                      Wid2,
  3685.                      Z  ,
  3686.                      X1 ,
  3687.                      0                           );
  3688.  
  3689.  
  3690.     END;  { For Z }
  3691.  
  3692.   END;  { RegionWrite }
  3693.  
  3694.   {────────────────────────────────────────────────────────────────────────}
  3695.  
  3696.   Procedure RealCursorGoto(       S,X,Y          : BYTE      );
  3697.  
  3698.   BEGIN
  3699.  
  3700.     VioSetCurPos( Y,
  3701.                   X,
  3702.                   0           );
  3703.  
  3704.   END;  { RealCursorGoto }
  3705.  
  3706.   {────────────────────────────────────────────────────────────────────────}
  3707.  
  3708.   Procedure CursorDown(           Sync           : BOOLEAN   );
  3709.  
  3710.   BEGIN
  3711.  
  3712.     With AS^ Do
  3713.     BEGIN
  3714.  
  3715.       Inc( CurY );
  3716.  
  3717.       If CurY > WinY2 Then
  3718.       BEGIN
  3719.  
  3720.         RegionScroll( WinX1,
  3721.                       WinY1,
  3722.                       WinX2,
  3723.                       WinY2,
  3724.                       -1        );
  3725.  
  3726.         Dec( CurY );
  3727.  
  3728.       END;  { If CurY }
  3729.  
  3730.       If (Sync) Then
  3731.         RealCursorGoto( IData^.AScreen-1, CurX, CurY );
  3732.  
  3733.     END; { With AS^ }
  3734.  
  3735.   END; { CursorDown }
  3736.  
  3737.   {────────────────────────────────────────────────────────────────────────}
  3738.  
  3739.   Procedure CursorNextChar(       Sync           : BOOLEAN   );
  3740.  
  3741.   BEGIN
  3742.  
  3743.     With   AS^ Do
  3744.     BEGIN
  3745.  
  3746.       Inc( CurX );
  3747.  
  3748.       If CurX > WinX2 Then
  3749.       BEGIN
  3750.  
  3751.         CurX := WinX1;
  3752.  
  3753.         CursorDown( Sync );
  3754.  
  3755.       END;  { If CurX }
  3756.  
  3757.       If (Sync) Then
  3758.         RealCursorGoto( IData^.AScreen-1, CurX, CurY );
  3759.  
  3760.     END; { With AS^ }
  3761.  
  3762.   END; { CursorNextChar }
  3763.  
  3764.   {────────────────────────────────────────────────────────────────────────}
  3765.  
  3766.   Procedure SwapCoords( Var A,B : WORD );
  3767.  
  3768.   Var
  3769.     Temp : WORD;
  3770.  
  3771.   BEGIN
  3772.  
  3773.     Temp := A;
  3774.     A    := B;
  3775.     B    := Temp;
  3776.  
  3777.   END;  { SwapCoords }
  3778.  
  3779.   {────────────────────────────────────────────────────────────────────────}
  3780.  
  3781.   Procedure MySetCursorType( CurType : WORD );
  3782.  
  3783.   Var
  3784.  
  3785.     VCI : TVioCursorInfo;
  3786.  
  3787.   BEGIN
  3788.  
  3789.     VioGetCurType( VCI, 0 );
  3790.  
  3791.     Case CurType of
  3792.  
  3793.       cctNone:
  3794.       BEGIN
  3795.         VCI.Attr := $FFFF;
  3796.       END;
  3797.  
  3798.       cctSmall:
  3799.       BEGIN
  3800.         VCI.ScanStart := $06;
  3801.         VCI.ScanEnd   := $07;
  3802.         VCI.Attr      := AS^.CurAttr;
  3803.       END;
  3804.  
  3805.       cctHalf:
  3806.       BEGIN
  3807.         VCI.ScanStart := $04;
  3808.         VCI.ScanEnd   := $07;
  3809.         VCI.Attr      := AS^.CurAttr;
  3810.       END;
  3811.  
  3812.       cctBig:
  3813.       BEGIN
  3814.         VCI.ScanStart := $00;
  3815.         VCI.ScanEnd   := $07;
  3816.         VCI.Attr      := AS^.CurAttr;
  3817.       END;
  3818.  
  3819.     ELSE
  3820.       VCI.ScanStart := $06;
  3821.       VCI.ScanEnd   := $07;
  3822.       VCI.Attr      := AS^.CurAttr;
  3823.     END;
  3824.  
  3825.     VioSetCurType( @VCI, 0 );
  3826.  
  3827.   END;
  3828.  
  3829.  
  3830.   {────────────────────────────────────────────────────────────────────────}
  3831.  
  3832. BEGIN  { VIOOutDriverProc }
  3833.  
  3834.   CallNext := TRUE;
  3835.  
  3836.   IData := ODP^.ID;
  3837.  
  3838.   If ODP^.Func<> ODF_DriverNew Then
  3839.   BEGIN
  3840.  
  3841.     AS    := @IData^.Screen[ IData^.AScreen ];
  3842.     YMult := IData^.YMult;
  3843.  
  3844.     {$IFDEF DEBUG}
  3845.       WriteLN( DebugFile, 'VIOOutDriverProc, ODP^.Func=',ODP^.Func );
  3846.       DebugWriteLN('');
  3847.     {$ENDIF}
  3848.  
  3849.   END;  { ODP^.Func }
  3850.  
  3851.   If ODP^.Status = 0 Then
  3852.   BEGIN
  3853.  
  3854.     Case ODP^.Func Of
  3855.  
  3856.       ODF_WriteBlock:
  3857.       BEGIN
  3858.  
  3859.         With AS^ DO
  3860.         BEGIN
  3861.  
  3862.           TheCell.Attr := CurAttr;
  3863.  
  3864.           For Z:=ODP^.Start to ODP^.Size Do
  3865.           BEGIN
  3866.  
  3867.             Case PCharBuff( ODP^.Buff)^[Z] Of
  3868.  
  3869.               #13:
  3870.               BEGIN
  3871.  
  3872.                 CurX := WinX1;
  3873.  
  3874.                 RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  3875.  
  3876.               END;  { #13 }
  3877.  
  3878.               #10:
  3879.               BEGIN
  3880.  
  3881.                 CursorDown( TRUE );
  3882.  
  3883.               END;
  3884.  
  3885.             Else
  3886.  
  3887.               TheCell.Char := PCharBuff( ODP^.Buff )^[Z];
  3888.  
  3889.               VioWrtCellStr( @TheCell,
  3890.                               2,
  3891.                               CurY,
  3892.                               CurX,
  3893.                               0                );
  3894.  
  3895.               { CursorNextChar( TRUE ); }
  3896.  
  3897.               CursorNextChar( FALSE );
  3898.  
  3899.             END;  { Case PCharBuff( ODP^.Buf)^[Z] }
  3900.  
  3901.           END; { For Z }
  3902.  
  3903.           RealCursorGoto( IData^.AScreen-1, CurX, CurY );
  3904.  
  3905.           ODP^.Start := ODP^.Size;
  3906.  
  3907.         END; { With AS^ }
  3908.  
  3909.       END;  { ODF_WriteBlock }
  3910.  
  3911.  
  3912.       {----}
  3913.  
  3914.  
  3915.       ODF_WriteChar:
  3916.       BEGIN
  3917.  
  3918.         With AS^ Do
  3919.         BEGIN
  3920.  
  3921.           Case ODP^.Ch Of
  3922.  
  3923.             #13:
  3924.             BEGIN
  3925.  
  3926.               CurX := WinX1;
  3927.  
  3928.               RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  3929.  
  3930.             END;  { #13 }
  3931.  
  3932.             #10:
  3933.             BEGIN
  3934.  
  3935.               CursorDown( TRUE );
  3936.  
  3937.             END;  { #10 }
  3938.  
  3939.           Else
  3940.  
  3941.  
  3942.             TheCell.Char := ODP^.CH;
  3943.             TheCell.Attr := CurAttr;
  3944.  
  3945.             VioWrtCellStr( @TheCell,
  3946.                             2,
  3947.                             CurY,
  3948.                             CurX,
  3949.                             0                );
  3950.  
  3951.             CursorNextChar( TRUE );
  3952.  
  3953.           END;  { Case ODP^.Ch }
  3954.  
  3955.         END; { With AS^ }
  3956.  
  3957.       END;  { ODF_WriteChar }
  3958.  
  3959.       {----}
  3960.  
  3961.  
  3962.       ODF_DriverNew:
  3963.       BEGIN
  3964.  
  3965.         IF @ODP^.OutDriverProc = @VIOOutDriverProc Then
  3966.         BEGIN
  3967.  
  3968.           {-------------------------}
  3969.           { Get a new Instance Data }
  3970.           { master node.            }
  3971.           {-------------------------}
  3972.  
  3973.           New( Idata );
  3974.  
  3975.  
  3976.           Idata^.VirtualCRT := FALSE;
  3977.  
  3978.           {----------------------------------}
  3979.           { Set IData up for the CGA/EGA/VGA }
  3980.           { monochrome text display mode     }
  3981.           {----------------------------------}
  3982.  
  3983.           InitVIOIData;
  3984.  
  3985.           {--------}
  3986.           { Return }
  3987.           {--------}
  3988.  
  3989.           ODP^.Status    := ODS_Install+ODS_Changed;
  3990.  
  3991.           ODP^.ID        := IData;
  3992.  
  3993.  
  3994.  
  3995.         END; { If ODP^.OutDriverProc --> Us }
  3996.  
  3997.       END; { ODF_DriverNew }
  3998.  
  3999.       {----}
  4000.  
  4001.       ODF_DriverOff:
  4002.       BEGIN
  4003.  
  4004.         If ODP^.Name^ = IData^.Name Then
  4005.         BEGIN
  4006.  
  4007.           Inc( Idata^.Off );
  4008.  
  4009.         END;  { If ODP^.Name^ }
  4010.  
  4011.       END;  { ODF_DriverOff }
  4012.  
  4013.       {----}
  4014.  
  4015.       ODF_DriverOn:
  4016.       BEGIN
  4017.  
  4018.         If ODP^.Name^ = IData^.Name Then
  4019.         BEGIN
  4020.  
  4021.           If Idata^.Off <> 0 Then
  4022.             Dec( Idata^.Off );
  4023.  
  4024.         END;  { ODP^.Name^ }
  4025.  
  4026.       END;  { ODF_DriverOn }
  4027.  
  4028.       {----}
  4029.  
  4030.       ODF_DriverDispose:
  4031.       BEGIN
  4032.  
  4033.         If ODP^.Name^ = IData^.Name Then
  4034.         BEGIN
  4035.  
  4036.           {RemoveFromOutDriverStack }
  4037.  
  4038.           Dispose( IData );
  4039.  
  4040.         END;  { If ODP^.Name^ }
  4041.  
  4042.       END;  { ODF_DriverDispose }
  4043.  
  4044.       {----}
  4045.  
  4046.  
  4047.       ODF_WriteVert:
  4048.       BEGIN
  4049.  
  4050.         With AS^ DO
  4051.         BEGIN
  4052.  
  4053.           TheCell.Attr := CurAttr;
  4054.  
  4055.           For Z:=1 to ODP^.Size Do
  4056.           BEGIN
  4057.  
  4058.  
  4059.             TheCell.Char := PCharBuff( ODP^.Buff )^[Z];
  4060.  
  4061.             VioWrtCellStr( @TheCell,
  4062.                             2,
  4063.                             CurY,
  4064.                             CurX,
  4065.                             0                );
  4066.  
  4067.             CursorDown( TRUE );
  4068.  
  4069.           END;  { For Z }
  4070.  
  4071.         END; { With AS^ }
  4072.  
  4073.       END;  { ODF_WriteVert }
  4074.  
  4075.       {----}
  4076.  
  4077.       ODF_WriteCharAt:
  4078.       BEGIN
  4079.  
  4080.         With AS^ Do
  4081.         BEGIN
  4082.  
  4083.           TheCell.Char := ODP^.CH;
  4084.           TheCell.Attr := ODP^.Attr;
  4085.  
  4086.           VioWrtCellStr( @TheCell,
  4087.                           2,
  4088.                           Pred(ODP^.Y1),
  4089.                           Pred(ODP^.X1),
  4090.                           0                );
  4091.  
  4092.  
  4093.           (*
  4094.           S^[ (Pred(ODP^.Y1)*YMult)+Pred(ODP^.X1) ].Char := ODP^.CH;
  4095.  
  4096.           S^[ (Pred(ODP^.Y1)*YMult)+Pred(ODP^.X1) ].Attr :=
  4097.                                             CRTColorMap[ ODP^.Attr ];
  4098.           *)
  4099.  
  4100.         END; { With AS^ }
  4101.  
  4102.       END;  { ODF_WriteCharAt }
  4103.  
  4104.       {----}
  4105.  
  4106.       ODF_WriteBlockAt:
  4107.       BEGIN
  4108.  
  4109.         With AS^ DO
  4110.         BEGIN
  4111.  
  4112.  
  4113.           VioWrtCharStrAttr( ODP^.Buff,
  4114.                              ODP^.Size,
  4115.                              Pred( ODP^.Y1 ),
  4116.                              Pred( ODP^.X1 ),
  4117.                              @ODP^.Attr,
  4118.                              0                  );
  4119.  
  4120.           (*
  4121.           TheCell.Attr := ODP^.Attr;
  4122.  
  4123.           For Z:=1 to ODP^.Size Do
  4124.           BEGIN
  4125.  
  4126.             TheCell.Char := PCharBuff( ODP^.Buff )^[Z];
  4127.  
  4128.  
  4129.  
  4130.             VioWrtCellStr( @TheCell,
  4131.                            2,
  4132.                            Pred(ODP^.Y1),
  4133.                            ODP^.X1+Z-2,
  4134.                            0                );
  4135.  
  4136.           END; { For Z }
  4137.           *)
  4138.  
  4139.         END; { With AS^ }
  4140.  
  4141.       END;  { ODF_WriteBlockAt }
  4142.  
  4143.       {----}
  4144.  
  4145.       ODF_WriteVertAt:
  4146.       BEGIN
  4147.  
  4148.         With AS^ DO
  4149.         BEGIN
  4150.  
  4151.           TheCell.Attr := ODP^.Attr;
  4152.  
  4153.           For Z:=1 to ODP^.Size Do
  4154.           BEGIN
  4155.  
  4156.             TheCell.Char := PCharBuff( ODP^.Buff )^[Z];
  4157.  
  4158.             VioWrtCellStr( @TheCell,
  4159.                            2,
  4160.                            ODP^.Y1+Z-2,
  4161.                            Pred( ODP^.X1 ),
  4162.                            0                );
  4163.  
  4164.  
  4165.           END;  { For Z }
  4166.  
  4167.         END; { With AS^ }
  4168.  
  4169.       END;  { ODF_WriteVertAt }
  4170.  
  4171.       {----}
  4172.  
  4173.       ODF_ClrEOL:
  4174.       BEGIN
  4175.  
  4176.         With AS^ DO
  4177.         BEGIN
  4178.  
  4179.           TheCell.Char := ' ';
  4180.           TheCell.Attr := CurAttr;
  4181.  
  4182.           VioWrtNCell( @TheCell,
  4183.                        Pred(WinX2-CurX),  {count}
  4184.                        CurY,
  4185.                        CurX,
  4186.                        0                     );
  4187.  
  4188.         END; { With AS^ }
  4189.  
  4190.       END;  { ODF_ClrEOL }
  4191.  
  4192.       {----}
  4193.  
  4194.       ODF_ClrScr:
  4195.       BEGIN
  4196.  
  4197.         With AS^ DO
  4198.         BEGIN
  4199.  
  4200.           { scroll the entire region off }
  4201.  
  4202.           RegionScroll( WinX1, WinY1,
  4203.                         WInX2, WinY2,
  4204.                         0-Succ(WInY2-WinY1)  );
  4205.  
  4206.           CurX := WinX1;
  4207.           CurY := WinY1;
  4208.  
  4209.           RealCursorGoto( IData^.Ascreen-1, CurX, Cury );
  4210.  
  4211.         END; { With AS^ }
  4212.  
  4213.  
  4214.       END;  { ODF_ClrScr }
  4215.  
  4216.       {----}
  4217.  
  4218.       ODF_DelLine:
  4219.       BEGIN
  4220.  
  4221.         With AS^ Do
  4222.         BEGIN
  4223.  
  4224.           RegionScroll( WinX1,
  4225.                         CurY,
  4226.                         WinX2,
  4227.                         WinY2,
  4228.                         -1         );
  4229.  
  4230.           { Cursor to WinX1?? }
  4231.  
  4232.         END;  { With AS^ }
  4233.  
  4234.       END;  { ODF_DelLine }
  4235.  
  4236.       {----}
  4237.  
  4238.       ODF_InsLine:
  4239.       BEGIN
  4240.  
  4241.         With AS^ Do
  4242.         BEGIN
  4243.  
  4244.           RegionScroll( WinX1,
  4245.                         CurY,
  4246.                         WinX2,
  4247.                         WinY2,
  4248.                         1         );
  4249.  
  4250.           { Cursor to WinX1?? }
  4251.  
  4252.         END;  { With AS^ }
  4253.  
  4254.       END;  { ODF_InsLine }
  4255.  
  4256.       {----}
  4257.  
  4258.       ODF_GotoXY:
  4259.       BEGIN
  4260.  
  4261.         With AS^Do
  4262.         BEGIN
  4263.  
  4264.           CurX := WinX1+(ODP^.X1-1);
  4265.           CurY := WinY1+(ODP^.Y1-1);
  4266.  
  4267.           RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  4268.  
  4269.         END;  { With AS^ }
  4270.  
  4271.       END;  { ODF_GotoXY }
  4272.  
  4273.       {----}
  4274.  
  4275.       ODF_Window:
  4276.       BEGIN
  4277.  
  4278.         With AS^ Do
  4279.         BEGIN
  4280.  
  4281.           WinX1 := ODP^.X1-1;
  4282.           WinY1 := ODP^.Y1-1;
  4283.           WinX2 := ODP^.X2-1;
  4284.           WinY2 := ODP^.Y2-1;
  4285.  
  4286.           If WinX2<WinX1 Then SwapCoords( WinX1, WinX2 );
  4287.           If WinY2<WinY1 Then SwapCoords( WinY1, WinY2 );
  4288.  
  4289.           CurX  := WinX1;
  4290.           CurY  := WinY1;
  4291.  
  4292.           RealCursorGoto( IData^.Ascreen-1, CurX, Cury );
  4293.  
  4294.           { call visionix services to set window coords }
  4295.  
  4296.         END;  { With AS^ }
  4297.  
  4298.       END;  { ODF_Window }
  4299.  
  4300.       {----}
  4301.  
  4302.       { 7 6 5 4 3 2 1 0 }
  4303.       { F B B B T T T T }
  4304.  
  4305.       ODF_ColorText:
  4306.       BEGIN
  4307.  
  4308.         With AS^ Do
  4309.         BEGIN
  4310.  
  4311.           CurAttr := (CurAttr AND $F0) + (ODP^.TheColor AND $0F);
  4312.  
  4313.         END;  { With AS^ }
  4314.  
  4315.       END;  { ODF_ColorText }
  4316.  
  4317.       {----}
  4318.  
  4319.       ODF_ColorBack:
  4320.       BEGIN
  4321.  
  4322.         With AS^ Do
  4323.         BEGIN
  4324.  
  4325.           CurAttr := (CurAttr AND $0F) + ((ODP^.TheColor AND $07) SHL 4);
  4326.  
  4327.         END;  { With AS^ }
  4328.  
  4329.       END;  { ODF_ColorBack }
  4330.  
  4331.       {----}
  4332.  
  4333.       ODF_GetWin:
  4334.       BEGIN
  4335.  
  4336.         With AS^ Do
  4337.         BEGIN
  4338.  
  4339.           ODP^.X1 := WinX1+1;
  4340.           ODP^.Y1 := WinY1+1;
  4341.           ODP^.X2 := WinX2+1;
  4342.           ODP^.Y2 := WinY2+1;
  4343.  
  4344.           ODP^.Status := ODS_Changed;
  4345.  
  4346.         END;  { With AS^ }
  4347.  
  4348.       END;  { ODF_GetWin }
  4349.  
  4350.       {----}
  4351.  
  4352.       ODF_GetAttr:
  4353.       BEGIN
  4354.  
  4355.         ODP^.Attr   := AS^.CurAttr;
  4356.  
  4357.         ODP^.Status := ODS_Changed;
  4358.  
  4359.       END;  { ODF_GetAttr }
  4360.  
  4361.       {----}
  4362.  
  4363.       ODF_SetAttr:
  4364.       BEGIN
  4365.  
  4366.         AS^.CurAttr := ODP^.Attr;
  4367.  
  4368.       END;  { ODF_SetAttr }
  4369.  
  4370.       {----}
  4371.  
  4372.       ODF_GetXY:
  4373.       BEGIN
  4374.  
  4375.         ODP^.X1 := (AS^.CurX+1)-AS^.WinX1;
  4376.         ODP^.Y1 := (AS^.CurY+1)-AS^.WinY1;
  4377.  
  4378.         ODP^.Status := ODS_Changed;
  4379.  
  4380.       END;  { ODF_GetXY }
  4381.  
  4382.       {----}
  4383.  
  4384.       ODF_GetNumScreens:
  4385.       BEGIN
  4386.  
  4387.         ODP^.Screens := IData^.NumScreens;
  4388.  
  4389.         ODP^.Status  := ODS_Changed;
  4390.  
  4391.       END;  { ODF_GetNumScreens }
  4392.  
  4393.       {----}
  4394.  
  4395.       ODF_GoScreen:
  4396.       BEGIN
  4397.  
  4398.         If ODP^.Screens <= IData^.NumScreens Then
  4399.           IData^.AScreen := ODP^.Screens;
  4400.  
  4401.       END;  { ODF_GoScreen }
  4402.  
  4403.       {----}
  4404.  
  4405.       ODF_SetCursorType:
  4406.       BEGIN
  4407.  
  4408.         MySetCursorType( ODP^.NumVal );
  4409.  
  4410.         AS^.CurType := ODP^.NumVal;
  4411.  
  4412.       END;  { ODF_SetCursorType }
  4413.  
  4414.       {----}
  4415.  
  4416.  
  4417.       ODF_DrawVLine:
  4418.       BEGIN
  4419.  
  4420.       END;  { ODF_DrawVLine }
  4421.  
  4422.       {----}
  4423.  
  4424.       ODF_DrawHLine:
  4425.       BEGIN
  4426.  
  4427.       END;  { ODF_DrawHLine }
  4428.  
  4429.       {----}
  4430.  
  4431.       ODF_DrawBox:
  4432.       BEGIN
  4433.  
  4434.       END;  { ODF_DrawBox }
  4435.  
  4436.       {----}
  4437.  
  4438.       ODF_ReadChar:
  4439.       BEGIN
  4440.  
  4441.         ODP^.CH := AS^.S^[ (Pred(ODP^.Y1)*YMult)+Pred(ODP^.X1) ].Char;
  4442.  
  4443.         ODP^.Status := ODS_Changed;
  4444.  
  4445.       END;  { ODF_ReadChar }
  4446.  
  4447.       {----}
  4448.  
  4449.       ODF_ReadAttr:
  4450.       BEGIN
  4451.  
  4452.         ODP^.Attr := AS^.S^[ (Pred(ODP^.Y1)*YMult)+ODP^.X1-1 ].Attr;
  4453.  
  4454.         ODP^.Status := ODS_Changed;
  4455.  
  4456.       END;  { ODF_ReadAttr }
  4457.  
  4458.       {----}
  4459.  
  4460.       ODF_WriteAttr:
  4461.       BEGIN
  4462.  
  4463.         VioWrtNAttr( @ODP^.Attr,
  4464.                      1,
  4465.                      Pred(ODP^.Y1),
  4466.                      Pred(ODP^.X1),
  4467.                      0              );
  4468.  
  4469.  
  4470.       END;  { ODF_WriteAttr }
  4471.  
  4472.       {----}
  4473.  
  4474.  
  4475.       ODF_QueryRegion:
  4476.       BEGIN
  4477.  
  4478.         ODP^.RegionSize := ((ODP^.Y2-ODP^.Y1)+1)*((ODP^.X2-ODP^.X1)+1)*2;
  4479.  
  4480.         ODP^.Status := ODS_Changed;
  4481.  
  4482.       END;  { ODF_QueryRegion }
  4483.  
  4484.       {----}
  4485.  
  4486.  
  4487.       ODF_ReadRegion:
  4488.       BEGIN
  4489.  
  4490.         If ODP^.Status AND ODS_Changed=0 Then
  4491.  
  4492.           RegionRead( Pred(ODP^.X1), Pred(ODP^.Y1),
  4493.                       Pred(ODP^.X2), Pred(ODP^.Y2), ODP^.Region );
  4494.  
  4495.         ODP^.Status := ODS_Changed;
  4496.  
  4497.  
  4498.       END;  { ODF_ReadRegion }
  4499.  
  4500.       {----}
  4501.  
  4502.       ODF_WriteRegion:
  4503.       BEGIN
  4504.  
  4505.         RegionWrite( ODP^.X1-1, ODP^.Y1-1,
  4506.                      ODP^.X2-1, ODP^.Y2-1, ODP^.Region );
  4507.  
  4508.  
  4509.       END;  { ODF_WriteRegion }
  4510.  
  4511.       {----}
  4512.  
  4513.  
  4514.       ODF_DriverRenew:
  4515.       BEGIN
  4516.  
  4517.       END;  { ODF_DriverRenew }
  4518.  
  4519.       {----}
  4520.  
  4521.       ODF_CursorUp:
  4522.       BEGIN
  4523.  
  4524.         With AS^Do
  4525.         BEGIN
  4526. (*
  4527.           If (CurY-ODP^.Numval) >= WinY1 Then
  4528.             Dec( CurY, ODP^.NumVal )
  4529.           Else
  4530.             CurY := WinY1;
  4531. *)
  4532.  
  4533.           For Z:=1 to ODP^.NumVal Do
  4534.             If CurY>WinY1 Then
  4535.               Dec(CurY);
  4536.  
  4537.  
  4538.           RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  4539.  
  4540.         END;  { With AS^ }
  4541.  
  4542.       END;  { ODF_CursorUp }
  4543.  
  4544.      {----}
  4545.  
  4546.       ODF_CursorDown:
  4547.       BEGIN
  4548.  
  4549.         With AS^Do
  4550.         BEGIN
  4551. (*
  4552.           If (CurY+ODP^.Numval) <= WinY2 Then
  4553.             Inc( CurY, ODP^.NumVal )
  4554.           Else
  4555.             CurY := WinY2;
  4556. *)
  4557.           For Z:=1 to ODP^.NumVal Do
  4558.             If CurY<WinY2 Then
  4559.               Inc(CurY);
  4560.  
  4561.           RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  4562.  
  4563.         END;  { With AS^ }
  4564.  
  4565.       END;  { ODF_CursorDown }
  4566.  
  4567.     {----}
  4568.  
  4569.       ODF_CursorLeft:
  4570.       BEGIN
  4571.  
  4572.         With AS^ Do
  4573.         BEGIN
  4574. (*
  4575.           If (CurX-ODP^.Numval) >= WinX1 Then
  4576.             Dec( CurY, ODP^.NumVal )
  4577.           Else
  4578.             CurX := WinX1;
  4579. *)
  4580.  
  4581.           For Z:=1 to ODP^.Numval Do
  4582.             If CurX>WinX1 Then
  4583.               Dec(CurX);
  4584.  
  4585.  
  4586.           RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  4587.  
  4588.         END;  { With AS^ }
  4589.  
  4590.       END;  { ODF_CursorLeft }
  4591.  
  4592.      {----}
  4593.  
  4594.       ODF_CursorRight:
  4595.       BEGIN
  4596.  
  4597.         With AS^Do
  4598.         BEGIN
  4599. (*
  4600.           If (CurX+ODP^.NumVal) <= WinX2 Then
  4601.             Inc( CurX, ODP^.NumVal )
  4602.           Else
  4603.             CurY := WinX2;
  4604. *)
  4605.           For Z:=1 to ODP^.Numval Do
  4606.             If CurX<WinX2 Then
  4607.               Inc(CurX);
  4608.  
  4609.  
  4610.           RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  4611.  
  4612.         END;  { With AS^ }
  4613.  
  4614.       END;  { ODF_CursorRight }
  4615.  
  4616.      {----}
  4617.  
  4618.       ODF_RegionScrUp:
  4619.       BEGIN
  4620.  
  4621.         RegionScroll( Pred(ODP^.X1), Pred(ODP^.Y1),
  4622.                       Pred(ODP^.X2), Pred(ODP^.Y2),
  4623.                       0-ODP^.NumVal         );
  4624.  
  4625.  
  4626.  
  4627.       END;  { ODF_RegionScrUp }
  4628.  
  4629.      {----}
  4630.  
  4631.       ODF_RegionScrDown:
  4632.       BEGIN
  4633.  
  4634.  
  4635.         RegionScroll( Pred(ODP^.X1), Pred(ODP^.Y1),
  4636.                       Pred(ODP^.X2), Pred(ODP^.Y2),
  4637.                       ODP^.NumVal         );
  4638.  
  4639.       END;  { ODF_RegionScrDown }
  4640.  
  4641.      {----}
  4642.  
  4643.       ODF_RegionCopy:
  4644.       BEGIN
  4645.  
  4646.       END;  { ODF_RegionCopy }
  4647.  
  4648.      {----}
  4649.  
  4650.       ODF_RegionFill:
  4651.       BEGIN
  4652.  
  4653.         With AS^ DO
  4654.         BEGIN
  4655.  
  4656.           TheCell.Char := ODP^.Ch;
  4657.           TheCell.Attr := ODP^.Attr;
  4658.  
  4659.           Z := Succ(ODP^.Y2-ODP^.Y1);
  4660.  
  4661.           For Z2:=Pred(ODP^.Y1) to Pred(ODP^.Y2) Do
  4662.           BEGIN
  4663.  
  4664.             VioWrtNCell( @TheCell,
  4665.                          Z,
  4666.                          Z2,
  4667.                          Pred(ODP^.X1),
  4668.                          0             );
  4669.  
  4670.           END; { For Z2 (y) }
  4671.  
  4672.         END; { With AS^ }
  4673.  
  4674.       END;  { ODF_RegionFill }
  4675.  
  4676.      {----}
  4677.  
  4678.       ODF_RegionFillA:
  4679.       BEGIN
  4680.  
  4681.         With AS^ DO
  4682.         BEGIN
  4683.  
  4684.           Z := Succ(ODP^.Y2-ODP^.Y1);
  4685.  
  4686.           For Z2:=Pred(ODP^.Y1) to Pred(ODP^.Y2) Do
  4687.           BEGIN
  4688.  
  4689.             VioWrtNAttr( @ODP^.Attr,
  4690.                          Z,
  4691.                          Z2,
  4692.                          Pred(ODP^.X1),
  4693.                          0             );
  4694.  
  4695.           END; { For Z2 (y) }
  4696.  
  4697.         END; { With AS^ }
  4698.  
  4699.       END;  { ODF_RegionFillA }
  4700.  
  4701.      {----}
  4702.  
  4703.       ODF_RegionFillC:
  4704.       BEGIN
  4705.  
  4706.         With AS^ DO
  4707.         BEGIN
  4708.  
  4709.  
  4710.           Z := Succ(ODP^.Y2-ODP^.Y1);
  4711.  
  4712.           For Z2:=Pred(ODP^.Y1) to Pred(ODP^.Y2) Do
  4713.           BEGIN
  4714.  
  4715.             VioWrtNChar( @ODP^.CH,
  4716.                          Z,
  4717.                          Z2,
  4718.                          Pred(ODP^.X1),
  4719.                          0             );
  4720.  
  4721.           END; { For Z2 (y) }
  4722.  
  4723.         END; { With AS^ }
  4724.  
  4725.  
  4726.       END;  { ODF_RegionFillC }
  4727.  
  4728.      {----}
  4729.  
  4730.       ODF_RepeatChar:
  4731.       BEGIN
  4732.  
  4733.         With AS^ Do
  4734.         BEGIN
  4735.  
  4736.           IF (ODP^.CH<>#13) and (ODP^.CH<>#10) Then
  4737.           BEGIN
  4738.  
  4739.             TheCell.Char := ODP^.Ch;
  4740.             TheCell.Attr := CurAttr;
  4741.  
  4742.             For Z:=1 to ODP^.NumVal Do
  4743.             BEGIN
  4744.  
  4745.               VioWrtCellStr( @TheCell,
  4746.                              2,
  4747.                              CurY,
  4748.                              CurX,
  4749.                              0                 );
  4750.  
  4751.               CursorNextChar( FALSE );
  4752.  
  4753.             END;  { For Z }
  4754.  
  4755.             RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  4756.  
  4757.           END;  { If ODP^.Ch }
  4758.  
  4759.         END; { With AS^ }
  4760.  
  4761.       END;  { ODF_RepeatChar }
  4762.  
  4763.      {----}
  4764.  
  4765.       ODF_RepeatCharAt:
  4766.       BEGIN
  4767.  
  4768.         With AS^ DO
  4769.         BEGIN
  4770.  
  4771.           TheCell.Char := ODP^.CH;
  4772.           TheCell.Attr := ODP^.Attr;
  4773.  
  4774.           VioWrtNCell( @TheCell,
  4775.                        ODP^.NumVal,
  4776.                        Pred(ODP^.Y1),
  4777.                        Pred(ODP^.X1),
  4778.                        0                     );
  4779.  
  4780.         END; { With AS^ }
  4781.  
  4782.       END;  { ODF_RepeatCharAt }
  4783.  
  4784.      {----}
  4785.  
  4786.       ODF_GetScreenSize:
  4787.       BEGIN
  4788.  
  4789.         With AS^ Do
  4790.         BEGIN
  4791.  
  4792.           ODP^.X1 := IData^.Cols;
  4793.           ODP^.Y1 := Idata^.Rows;
  4794.  
  4795.         END;  { With AS^ }
  4796.  
  4797.       END;  { ODF_GetScreenSize }
  4798.  
  4799.      {----}
  4800.  
  4801.      ODF_RepeatBlock:
  4802.      BEGIN
  4803.  
  4804.         With AS^ DO
  4805.         BEGIN
  4806.  
  4807.           Z3 := ODP^.Start;
  4808.  
  4809.           TheCell.Attr := CurAttr;
  4810.  
  4811.           For Z2:=1 to ODP^.NumVal Do
  4812.           BEGIN
  4813.  
  4814.             For Z:=Z3 to ODP^.Size Do
  4815.             BEGIN
  4816.  
  4817.               Case PCharBuff( ODP^.Buff)^[Z] Of
  4818.  
  4819.                 #13:
  4820.                 BEGIN
  4821.  
  4822.                   CurX := WinX1;
  4823.  
  4824.                   RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  4825.  
  4826.                 END;  { #13 }
  4827.  
  4828.                 #10:
  4829.                 BEGIN
  4830.  
  4831.                   CursorDown( TRUE );
  4832.  
  4833.                 END;
  4834.  
  4835.               Else
  4836.  
  4837.  
  4838.                 TheCell.Char := PCharBuff( ODP^.Buff )^[Z];
  4839.  
  4840.                 VioWrtCellStr( @TheCell,
  4841.                                 2,
  4842.                                 CurY,
  4843.                                 CurX,
  4844.                                 0                );
  4845.  
  4846.                 CursorNextChar( FALSE );
  4847.  
  4848.               END;  { Case PCharBuff( ODP^.Buf)^[Z] }
  4849.  
  4850.             END; { For Z }
  4851.  
  4852.             Z3 := 1;
  4853.  
  4854.           END; { for Z2 }
  4855.  
  4856.           RealCursorGoto( IData^.Ascreen-1, CurX, CurY );
  4857.  
  4858.         END; { With AS^ }
  4859.  
  4860.         ODP^.Start := ODP^.Size;
  4861.  
  4862.      END; { ODF_Repeatblock }
  4863.  
  4864.  
  4865.  
  4866.      {----}
  4867.      {----}
  4868.  
  4869.     Else { Else Case }
  4870.  
  4871.     END;  { Case ODP^.Func }
  4872.  
  4873.   END; { If ODP^.Status = 0 }
  4874.  
  4875.   CallNextDriver( ODP );
  4876.  
  4877. END;  { VIOOutDriverProc }
  4878.  
  4879. {$ENDIF}
  4880.  
  4881. {────────────────────────────────────────────────────────────────────────────}
  4882.  
  4883.  
  4884. (*-
  4885.  
  4886. [FUNCTION]
  4887.  
  4888. Procedure CRTVGASetCharWidth(     CWid           : BYTE      );
  4889.  
  4890. [PARAMETERS]
  4891.  
  4892. CWid        Desired New Character Width
  4893.  
  4894. [RETURNS]
  4895.  
  4896. (None)
  4897.  
  4898. [DESCRIPTION]
  4899.  
  4900. Sets the VGA Character Width to a given pixel Width.
  4901.  
  4902. Sets the text mode character width of a vga display.  normally,
  4903. a character in vga mode is 9 pixels wide.  However, the font
  4904. tables only have 8 chars per pixel.  This is a problem when
  4905. characters need to "touch" each other.
  4906.  
  4907. [SEE-ALSO]
  4908.  
  4909. [EXAMPLE]
  4910.  
  4911. -*)
  4912.  
  4913. Procedure CRTVGASetCharWidth(     CWid           : BYTE      );
  4914.  
  4915. Var
  4916.  
  4917. {$IFNDEF OS2}
  4918.   R : REGISTERS;
  4919. {$ENDIF}
  4920.   B : BYTE;
  4921.  
  4922. BEGIN
  4923.  
  4924. {$IFDEF OS2}
  4925.  
  4926. {$ELSE}
  4927.  
  4928.   If CWid in [8..9] Then
  4929.   BEGIN
  4930.  
  4931.     Case CWid Of
  4932.  
  4933.       8 :
  4934.       BEGIN
  4935.  
  4936.         B    := (Port[ $3CC ] and NOT(4+8));
  4937.  
  4938.         R.BX := $0001;
  4939.  
  4940.       END;  { 8 }
  4941.  
  4942.       9 :
  4943.       BEGIN
  4944.  
  4945.         B    := (Port[ $3CC ] and NOT(4+8)) or 4;
  4946.  
  4947.         R.BX := $0800;
  4948.  
  4949.       END;  { 9 }
  4950.  
  4951.     END; { Case CWid }
  4952.  
  4953.     Port[ $3C2 ] := B;
  4954.  
  4955.     ASM CLI; END;
  4956.  
  4957.     PortW[ $3C4 ] := $0100;
  4958.     PortW[ $3C4 ] := $01 + R.BL SHL 8;
  4959.     PortW[ $3C4 ] := $0300;
  4960.  
  4961.     ASM STI; END;
  4962.  
  4963.     R.AX := $1000;
  4964.     R.BL := $13;
  4965.     R.ES := $0;
  4966.     R.DS := $0;
  4967.  
  4968.     Intr( $10, R );
  4969.  
  4970.   END;  { If CWid }
  4971.  
  4972. {$ENDIF}
  4973.  
  4974. END;  { CRTVGASetCharWidth }
  4975.  
  4976.  
  4977. {────────────────────────────────────────────────────────────────────────────}
  4978.  
  4979. (*-
  4980.  
  4981. [FUNCTION]
  4982.  
  4983. Procedure CRTInDriverProc(        IDP            : PInDriverPacket );
  4984.  
  4985. [PARAMETERS]
  4986.  
  4987. IDP         Pointer To In-Data Driver Packet
  4988.  
  4989. [RETURNS]
  4990.  
  4991. (None)
  4992.  
  4993. [DESCRIPTION]
  4994.  
  4995. This is THE Input CRT Driver Procedure.  It handles all the Input
  4996. CRT Related Functions.
  4997.  
  4998. This is the in  driver procedure which is placed on the
  4999. CRT    in-channel
  5000. it takes VIN driver requests and performs them on the
  5001. keyboard
  5002.  
  5003. See VIN for more information
  5004.  
  5005. [SEE-ALSO]
  5006.  
  5007. [EXAMPLE]
  5008.  
  5009. -*)
  5010.  
  5011. Procedure CRTInDriverProc(        IDP            : PInDriverPacket );
  5012.  
  5013. Type
  5014.  
  5015.   TDefKdInstanceData = Record
  5016.  
  5017.     KeyBuff    : PString;
  5018.     Off        : WORD;
  5019.     Name       : TProcName;
  5020.  
  5021.     ExtKeyChar : CHAR;
  5022.  
  5023.   END;
  5024.  
  5025.   PDefKDInstanceData = ^TDefKDInstanceData;
  5026.  
  5027. Var
  5028.   IData      : PDefKDInstanceData;
  5029.  
  5030.   KeyW       : WORD;
  5031.  
  5032.   {────────────────────────────────────────────────────────────────────────}
  5033.  
  5034.   Function MyKeyPressed                                        : BOOLEAN;
  5035.  
  5036.   {$IFNDEF OS2}
  5037.  
  5038.     Var
  5039.       R : REGISTERS;
  5040.  
  5041.     BEGIN
  5042.  
  5043.       MyKeyPressed := BiosMemMap^.KbdBufHead<>BiosMemMap^.KbdBufTail;
  5044.  
  5045.     END;  { MyKeyPressed }
  5046.  
  5047.   {$ELSE}
  5048.  
  5049.     Var
  5050.       KeyInfo : TKbdKeyInfo;
  5051.  
  5052.     BEGIN
  5053.  
  5054.       KbdPeek(KeyInfo,0);
  5055.  
  5056.       MyKeyPressed := ((KeyInfo.fbStatus AND $40) <> 0);
  5057.  
  5058.       (*
  5059.       MyKeyPressed := (IData^.ExtKeyChar <> #0         ) or
  5060.                       ( (KeyInfo.fbStatus And $40) <> 0);
  5061.       *)
  5062.  
  5063.     END;  { MyKeyPressed }
  5064.  
  5065.  
  5066.   {$ENDIF}
  5067.  
  5068.   {────────────────────────────────────────────────────────────────────────}
  5069.  
  5070.   Function MyReadKey                                           : WORD;
  5071.  
  5072.   {$IFNDEF OS2}
  5073.  
  5074.     Var
  5075.       R : REGISTERS;
  5076.  
  5077.  
  5078.     BEGIN
  5079.  
  5080.       R.AH := $00;
  5081.       R.ES := $00;
  5082.       R.DS := $00;
  5083.  
  5084.       Intr( $16, R );
  5085.  
  5086.       MyReadKey := R.AX;
  5087.  
  5088.  
  5089.     END;  { MyReadKey }
  5090.  
  5091.   {$ELSE}
  5092.  
  5093.     Var
  5094.  
  5095.       KeyInfo : TKbdKeyInfo;
  5096.       W       : WORD;
  5097.  
  5098.     BEGIN
  5099.  
  5100.       KbdCharIn( KeyInfo, 0, 0 );
  5101.  
  5102.       W := ( Byte(KeyInfo.chscan) SHL 8) + Byte(KeyInfo.ChChar);
  5103.  
  5104.       MyReadKey := W;
  5105.  
  5106.       (*
  5107.       If IData^.ExtKeyChar <> #0 Then
  5108.       BEGIN
  5109.  
  5110.         MyReadKey := Idata^.ExtKeyChar;
  5111.  
  5112.         IData^.ExtKeyChar := #0;
  5113.  
  5114.       END
  5115.       ELSE
  5116.       BEGIN
  5117.  
  5118.         KbdCharIn( KeyInfo, 0, 0 );
  5119.  
  5120.         If KeyInfo.chChar = #0 Then
  5121.           ExtKeyChar := KeyInfo.chScan;
  5122.  
  5123.         MyReadKey := KeyInfo.chChar;
  5124.  
  5125.       END;
  5126.       *)
  5127.  
  5128.     END;
  5129.  
  5130.   {$ENDIF}
  5131.  
  5132.  
  5133.   {────────────────────────────────────────────────────────────────────────}
  5134.  
  5135. BEGIN  { CRTInDriverProc }
  5136.  
  5137.   IData := IDP^.ID;
  5138.  
  5139.   If IDP^.Status = 0 Then
  5140.   BEGIN
  5141.  
  5142.     Case IDP^.Func Of
  5143.  
  5144.       IDF_DriverNew:
  5145.       BEGIN
  5146.  
  5147.         IF @IDP^.InDriverProc = @CRTInDriverProc Then
  5148.         BEGIN
  5149.  
  5150.           New( Idata );
  5151.  
  5152.           IData^.Name    := IDP^.Name^;
  5153.           IData^.KeyBuff := IDP^.SysKeyBuff;
  5154.           IData^.Off     := 0;
  5155.  
  5156.           IDP^.Status := IDS_Install+IDS_Changed;
  5157.  
  5158.           IDP^.ID := IData;
  5159.  
  5160.         END;  { If @IDP^.InDriverProc }
  5161.  
  5162.       END;  { IDF_DriverNew }
  5163.  
  5164.       {----}
  5165.  
  5166.       IDF_DriverOff:
  5167.       BEGIN
  5168.  
  5169.         If IDP^.Name^ = IData^.Name Then
  5170.         BEGIN
  5171.  
  5172.           Inc( Idata^.Off );
  5173.  
  5174.         END;  { IDP^.Name^ }
  5175.  
  5176.       END;  { IDF_DriverOff }
  5177.  
  5178.       {----}
  5179.  
  5180.       IDF_DriverOn:
  5181.       BEGIN
  5182.  
  5183.         If IDP^.Name^ = IData^.Name Then
  5184.         BEGIN
  5185.  
  5186.           If Idata^.Off <> 0 Then
  5187.             Dec( Idata^.Off );
  5188.  
  5189.         END;  { If IDP^.Name^ }
  5190.  
  5191.       END;  { IDF_DriverOn }
  5192.  
  5193.       {----}
  5194.  
  5195.       IDF_DriverDispose:
  5196.       BEGIN
  5197.  
  5198.         If IDP^.Name^ = IData^.Name Then
  5199.         BEGIN
  5200.  
  5201.           {RemoveFromInDriverStack }
  5202.  
  5203.           Dispose( IData );
  5204.  
  5205.         END;  { If IDP^.Name^ }
  5206.  
  5207.       END;  { IDF_DriverDispose }
  5208.  
  5209.       {----}
  5210.  
  5211.       IDF_Look:
  5212.       If IData^.Off=0 Then
  5213.       BEGIN
  5214.  
  5215.         If Idata^.KeyBuff^<>'' Then
  5216.         BEGIN
  5217.  
  5218.           IDP^.Key := IData^.KeyBuff^[1];
  5219.  
  5220.           IDP^.Status := IDS_Changed;
  5221.  
  5222.         END  { If IData^.KeyBuff^ }
  5223.         Else
  5224.         BEGIN
  5225.  
  5226.           If MyKeyPressed Then
  5227.           BEGIN
  5228.  
  5229.             KeyW := MyReadKey;
  5230.  
  5231.             IDP^.Key := Char(Lo(Keyw));
  5232.  
  5233.             If Lo(KeyW)=0 Then
  5234.               IData^.KeyBuff^ := IData^.KeyBuff ^ + Char(Lo(Keyw)) +
  5235.                                                     Char(Hi(KeyW)) ;
  5236.  
  5237.             IDP^.Status := IDS_Changed;
  5238.  
  5239.           END;  { If MyKeyPressed }
  5240.  
  5241.         END;  { If IData^.KeyBuff^ / Else }
  5242.  
  5243.       END;  { IDF_Look }
  5244.  
  5245.       {----}
  5246.  
  5247.       IDF_Read:
  5248.       If IData^.Off=0 Then
  5249.       BEGIN
  5250.  
  5251.         If IData^.KeyBuff^<>'' Then
  5252.         BEGIN
  5253.  
  5254.           IDP^.Key := IData^.KeyBuff^[1];
  5255.  
  5256.           Delete( IData^.KeyBuff^, 1, 1 );
  5257.  
  5258.           IDP^.Status := IDS_Changed;
  5259.  
  5260.           If IDP^.Key=#0 Then
  5261.             IDP^.Status := IDP^.Status + IDS_Sequence;
  5262.  
  5263.         END  { If IData^.KeyBuff^ }
  5264.         Else
  5265.         BEGIN
  5266.  
  5267.           If MyKeyPressed Then
  5268.           BEGIN
  5269.  
  5270.             KeyW := MyReadKey;
  5271.  
  5272.             IDP^.Key := Char(Lo(KeyW));
  5273.  
  5274.             If Lo(Keyw)=0 Then
  5275.               IData^.KeyBuff^ := IData^.KeyBuff ^ + Char(Hi(Keyw));
  5276.  
  5277.             IDP^.Status := IDS_Changed;
  5278.  
  5279.             If IDP^.Key = #0 Then
  5280.               IDP^.Status := IDP^.Status + IDS_Sequence;
  5281.  
  5282.           END;  { If MyKeyPressed }
  5283.  
  5284.         END;  { If IData^.KeyBuff^ / Else }
  5285.  
  5286.       END;  { IDF_Read }
  5287.  
  5288.       {----}
  5289.  
  5290.       IDF_Write:
  5291.       BEGIN
  5292.  
  5293.         IData^.KeyBuff^ := IData^.KeyBuff^ + IDP^.KeysToWrite^;
  5294.  
  5295.         IDP^.Status := IDS_Changed;
  5296.  
  5297.       END;  { IDF_Write }
  5298.  
  5299.       {----}
  5300.  
  5301.       IDF_State:
  5302.       BEGIN
  5303.  
  5304.         { Read Shift/Ctrl/Alt State }
  5305.  
  5306.       END;  { IDF_State }
  5307.  
  5308.       {----}
  5309.  
  5310.       IDF_Flush:
  5311.       IF IData^.Off=0 Then
  5312.       BEGIN
  5313.  
  5314.         IData^.KeyBuff^ := '';
  5315.  
  5316.         While MyKeyPressed DO
  5317.           MyReadKey;
  5318.  
  5319.         (*
  5320.         IData^.KeyBuff^ := '';
  5321.         BiosMemMap^.KbdBufTail := BiosMemMap^.KbdBufHead;
  5322.         *)
  5323.  
  5324.         IDP^.Status := IDS_Changed;
  5325.  
  5326.       END;  { If IData^.Off }
  5327.  
  5328.       { IDF_Flush }
  5329.  
  5330.       {----}
  5331.  
  5332.       IDF_Pressed:
  5333.       IF (IData^.Off=0) and (IDP^.Pressed=FALSE) Then
  5334.       BEGIN
  5335.  
  5336.         IDP^.Pressed := ( MyKeyPressed ) Or ( IData^.KeyBuff^[0]<>#0 );
  5337.  
  5338.         If IDP^.Pressed=TRUE Then
  5339.           IDP^.Status := IDS_Changed;
  5340.  
  5341.       END;  { If IData^.Off }
  5342.  
  5343.     Else { Case Else }
  5344.  
  5345.     END;  { Case IDP^.Func }
  5346.  
  5347.   END; { If IDP^.Status = 0 }
  5348.  
  5349. END;  { CRTInDriverProc }
  5350.  
  5351. {────────────────────────────────────────────────────────────────────────────}
  5352.  
  5353. (*-
  5354.  
  5355. [FUNCTION]
  5356.  
  5357. Procedure SyncAttr;
  5358.  
  5359. [PARAMETERS]
  5360.  
  5361. (None)
  5362.  
  5363. [RETURNS]
  5364.  
  5365. (None)
  5366.  
  5367. [DESCRIPTION]
  5368.  
  5369. Syncs the CRT out-channel with the current TextAttr setting should only
  5370. need to be done when it is beleived that a driver on the CRT out-channel
  5371. is "lost", and this should only happen when serial-port out-channel
  5372. drivers are put on the crt out-channel
  5373.  
  5374. [SEE-ALSO]
  5375.  
  5376. [EXAMPLE]
  5377.  
  5378. -*)
  5379.  
  5380. Procedure SyncAttr;
  5381.  
  5382. BEGIN
  5383.  
  5384.   TextAttrSet( TextAttr );
  5385.  
  5386. END;
  5387.  
  5388. {────────────────────────────────────────────────────────────────────────────}
  5389.  
  5390. (*-
  5391.  
  5392. [FUNCTION]
  5393.  
  5394. Procedure SyncWind;
  5395.  
  5396. [PARAMETERS]
  5397.  
  5398. (None)
  5399.  
  5400. [RETURNS]
  5401.  
  5402. (None)
  5403.  
  5404. [DESCRIPTION]
  5405.  
  5406. Syncs the CRT out-channel with the current window setting should only
  5407. need to be done when it is beleived that a driver on the CRT out-channel
  5408. is "lost", and this should only happen when serial-port out-channel
  5409. drivers are put on the crt out-channel
  5410.  
  5411. [SEE-ALSO]
  5412.  
  5413. [EXAMPLE]
  5414.  
  5415. -*)
  5416.  
  5417. Procedure SyncWind;
  5418.  
  5419. BEGIN
  5420.  
  5421.   Window( Lo(WindMin)+1, Hi(WindMin)+1,
  5422.           Lo(WindMax)+1, Hi(WindMax)+1  );
  5423.  
  5424. END;
  5425.  
  5426. {────────────────────────────────────────────────────────────────────────────}
  5427.  
  5428. (*-
  5429.  
  5430. [FUNCTION]
  5431.  
  5432. Function CRTTextNullProc(     Var F              : TextRec   ) : INTEGER; Far;
  5433.  
  5434. [PARAMETERS]
  5435.  
  5436. F           VAR Text File Record (?)
  5437.  
  5438. [RETURNS]
  5439.  
  5440. [DESCRIPTION]
  5441.  
  5442. [SEE-ALSO]
  5443.  
  5444. [EXAMPLE]
  5445.  
  5446. -*)
  5447.  
  5448. Function CRTTextNullProc(     Var F              : TextRec   ) : INTEGER; Far;
  5449.  
  5450. BEGIN
  5451.  
  5452. END;  { CRTTextNullProc }
  5453.  
  5454. {────────────────────────────────────────────────────────────────────────────}
  5455.  
  5456. (*-
  5457.  
  5458. [FUNCTION]
  5459.  
  5460. Function CRTTextOutProc(      Var F              : TextRec   ) : INTEGER; Far;
  5461.  
  5462. [PARAMETERS]
  5463.  
  5464. F           VAR ?
  5465.  
  5466. [RETURNS]
  5467.  
  5468. [DESCRIPTION]
  5469.  
  5470. [SEE-ALSO]
  5471.  
  5472. [EXAMPLE]
  5473.  
  5474. -*)
  5475.  
  5476. Function CRTTextOutProc(      Var F              : TextRec   ) : INTEGER; Far;
  5477.  
  5478. BEGIN
  5479.  
  5480.   If TextAttr<>KnownTextAttr Then
  5481.     SyncAttr;
  5482.  
  5483.   If (WindMin<>KnownWindMin) or (WindMax<>KnownWindMax) Then
  5484.     SyncWind;
  5485.  
  5486.   If F.BufPos <> 0 Then
  5487.     VOutWriteBlock( CrtOCH, F.BufPtr, F.BufPos );
  5488.  
  5489.   F.BufPos := 0;
  5490.  
  5491.   CRTTextOutProc := 0;
  5492.  
  5493. END;  { CRTTextOutProc }
  5494.  
  5495. {────────────────────────────────────────────────────────────────────────────}
  5496.  
  5497. (*-
  5498.  
  5499. [FUNCTION]
  5500.  
  5501. Function CRTTextInProc(       Var F              : TextRec ) : INTEGER; Far;
  5502.  
  5503. [PARAMETERS]
  5504.  
  5505. F           VAR Handle to File Text Record
  5506.  
  5507. [RETURNS]
  5508.  
  5509. [DESCRIPTION]
  5510.  
  5511. [SEE-ALSO]
  5512.  
  5513. [EXAMPLE]
  5514.  
  5515. -*)
  5516.  
  5517. Function CRTTextInProc(       Var F              : TextRec ) : INTEGER; Far;
  5518.  
  5519. BEGIN
  5520.  
  5521.   CRTTextInProc := 1;
  5522.  
  5523. END;  { CRTTextInProc }
  5524.  
  5525. {────────────────────────────────────────────────────────────────────────────}
  5526.  
  5527. (*-
  5528.  
  5529. [FUNCTION]
  5530.  
  5531. Function CRTTextOpenProc(     Var F              : TextRec   ) : INTEGER; Far;
  5532.  
  5533. [PARAMETERS]
  5534.  
  5535. F           VAR ?
  5536.  
  5537. [RETURNS]
  5538.  
  5539. [DESCRIPTION]
  5540.  
  5541. [SEE-ALSO]
  5542.  
  5543. [EXAMPLE]
  5544.  
  5545. -*)
  5546.  
  5547. Function CRTTextOpenProc(     Var F              : TextRec   ) : INTEGER; Far;
  5548.  
  5549. BEGIN
  5550.  
  5551.   With F Do
  5552.   BEGIN
  5553.  
  5554.     If Mode <> fmInput Then
  5555.     BEGIN
  5556.  
  5557.       Mode      := fmOutput;
  5558.  
  5559.       FlushFunc := @CRTTextOutProc;
  5560.       CloseFunc := @CRTTextNullProc;
  5561.       InOutFunc := @CRTTextOutProc;
  5562.  
  5563.     END  { If Mode }
  5564.     Else
  5565.     BEGIN
  5566.  
  5567.       FlushFunc := @CRTTextNullProc;
  5568.       CloseFunc := @CRTTextNullProc;
  5569.       InOutFunc := @CRTTextInProc;
  5570.  
  5571.     END; { If Mode <> fmInput / ELSE }
  5572.  
  5573.   END; { With F }
  5574.  
  5575.   CRTTextOpenProc := 0;
  5576.  
  5577. END;  { CRTTextOpenProc }
  5578.  
  5579. {────────────────────────────────────────────────────────────────────────────}
  5580.  
  5581. (*-
  5582.  
  5583. [FUNCTION]
  5584.  
  5585. Procedure AssignCRT(          Var F              : Text      );
  5586.  
  5587. [PARAMETERS]
  5588.  
  5589. F           VAR Output File Handle (The Screen)
  5590.  
  5591. [RETURNS]
  5592.  
  5593. (None)
  5594.  
  5595. [DESCRIPTION]
  5596.  
  5597. Assigns a text-file to the CRT.
  5598.  
  5599. [SEE-ALSO]
  5600.  
  5601. [EXAMPLE]
  5602.  
  5603. -*)
  5604.  
  5605. Procedure AssignCRT(          Var F              : Text      );
  5606.  
  5607. BEGIN
  5608.  
  5609.   With TextRec( F ) DO
  5610.   BEGIN
  5611.  
  5612.     BufSize  := 128;
  5613.     BufPtr   := @Buffer;
  5614.  
  5615.     OpenFunc := @CRTTextOpenProc;
  5616.  
  5617.     BufPos   := 0;
  5618.  
  5619.     Handle   := 0;
  5620.  
  5621.   END; { With TextRec( F ) }
  5622.  
  5623. END;  { AssignCRT }
  5624.  
  5625. {────────────────────────────────────────────────────────────────────────────}
  5626.  
  5627. (*-
  5628.  
  5629. [FUNCTION]
  5630.  
  5631. Procedure ClrEOL;
  5632.  
  5633. [PARAMETERS]
  5634.  
  5635. (None)
  5636.  
  5637. [RETURNS]
  5638.  
  5639. (None)
  5640.  
  5641. [DESCRIPTION]
  5642.  
  5643. Clears a Line using the Current Color Attributes from the current
  5644. Cursor Position to the End of the Screen.  If we are within a Window,
  5645. then the action is restricted to within this Window.
  5646.  
  5647. Clears to the end of the line from the current cursor position.
  5648.  
  5649. [SEE-ALSO]
  5650.  
  5651. [EXAMPLE]
  5652.  
  5653. -*)
  5654.  
  5655. Procedure ClrEOL;
  5656.  
  5657. BEGIN
  5658.  
  5659.   If TextAttr<>KnownTextAttr Then
  5660.     SyncAttr;
  5661.  
  5662.   If (WindMin<>KnownWindMin) or (WindMax<>KnownWindMax) Then
  5663.     SyncWind;
  5664.  
  5665.   VOutClrEOL( CrtOCH );
  5666.  
  5667. END;  { ClrEOL }
  5668.  
  5669. {────────────────────────────────────────────────────────────────────────────}
  5670.  
  5671. (*-
  5672.  
  5673. [FUNCTION]
  5674.  
  5675. Procedure ClrScr;
  5676.  
  5677. [PARAMETERS]
  5678.  
  5679. (None)
  5680.  
  5681. [RETURNS]
  5682.  
  5683. (None)
  5684.  
  5685. [DESCRIPTION]
  5686.  
  5687. Clears the Screen by filling it with Spaces using the current color
  5688. attributes.  If we are within a Window then the Clear Screen is
  5689. restricted to just within this Window.
  5690.  
  5691. Clears the screen or the active window.
  5692.  
  5693. [SEE-ALSO]
  5694.  
  5695. [EXAMPLE]
  5696.  
  5697. -*)
  5698.  
  5699. Procedure ClrScr;
  5700.  
  5701. BEGIN
  5702.  
  5703.   If TextAttr<>KnownTextAttr Then
  5704.     SyncAttr;
  5705.  
  5706.   If (WindMin<>KnownWindMin) or (WindMax<>KnownWindMax) Then
  5707.     SyncWind;
  5708.  
  5709.   VOutClrScr( CrtOCH );
  5710.  
  5711. END;  { ClrScr }
  5712.  
  5713. {────────────────────────────────────────────────────────────────────────────}
  5714.  
  5715. (*-
  5716.  
  5717. [FUNCTION]
  5718.  
  5719. Procedure DelayOneMS;
  5720.  
  5721. [PARAMETERS]
  5722.  
  5723. (None)
  5724.  
  5725. [RETURNS]
  5726.  
  5727. (None)
  5728.  
  5729. [DESCRIPTION]
  5730.  
  5731. Delays activity for a Single Millisecond, then resumes.
  5732. [SEE-ALSO]
  5733.  
  5734. [EXAMPLE]
  5735.  
  5736. -*)
  5737.  
  5738. {$IFNDEF OS2}
  5739.  
  5740. Procedure DelayOneMS;
  5741.  
  5742. Assembler;
  5743. ASM
  5744.  
  5745.   PUSH CX
  5746.   MOV CX, DelayOfMS
  5747.  
  5748. @1:
  5749.  
  5750.   LOOP @1
  5751.   POP CX
  5752.  
  5753. END;  { DelayOneMS }
  5754.  
  5755. {$ENDIF}
  5756.  
  5757. {────────────────────────────────────────────────────────────────────────────}
  5758.  
  5759. (*-
  5760.  
  5761. [FUNCTION]
  5762.  
  5763. Procedure Delay(                  MS             : WORD      );
  5764.  
  5765. [PARAMETERS]
  5766.  
  5767. MS          Number of Milliseconds Delay
  5768.  
  5769. [RETURNS]
  5770.  
  5771. (None)
  5772.  
  5773. [DESCRIPTION]
  5774.  
  5775. Delays activity for a given number of Milliseconds, then Resumes.
  5776.  
  5777. Delays for the specified number of milliseconds.
  5778.  
  5779. [SEE-ALSO]
  5780.  
  5781. [EXAMPLE]
  5782.  
  5783. -*)
  5784.  
  5785. Procedure Delay(                  MS             : WORD      );
  5786.  
  5787. {$IFNDEF OS2}
  5788.  
  5789. Assembler;
  5790. ASM
  5791.  
  5792.   MOV CX, ms
  5793.   JCXZ @2
  5794.  
  5795. @1:
  5796.  
  5797.   CALL DelayOneMS
  5798.   LOOP @1
  5799.  
  5800. @2:
  5801.  
  5802. END;  { Delay }
  5803.  
  5804. {$ELSE}
  5805.  
  5806. BEGIN
  5807.  
  5808.   DosSleep( MS );
  5809.  
  5810. END;
  5811.  
  5812. {$ENDIF}
  5813.  
  5814. {────────────────────────────────────────────────────────────────────────────}
  5815.  
  5816. (*-
  5817.  
  5818. [FUNCTION]
  5819.  
  5820. Procedure FindDelay;
  5821.  
  5822. [PARAMETERS]
  5823.  
  5824. (None)
  5825.  
  5826. [RETURNS]
  5827.  
  5828. (None)
  5829.  
  5830. [DESCRIPTION]
  5831.  
  5832. Determines the proper Time Delay Rate for this computer based upon how
  5833. long it takes to execute a given delay.
  5834.  
  5835. [SEE-ALSO]
  5836.  
  5837. [EXAMPLE]
  5838.  
  5839. -*)
  5840.  
  5841. {$IFNDEF OS2}
  5842.  
  5843. Procedure FindDelay;
  5844.  
  5845. Assembler;
  5846. ASM
  5847.  
  5848.   MOV  DelayOfMS, 55
  5849.   MOV  AX, Seg0040
  5850.   MOV  ES, AX
  5851.   MOV  DI, 6Ch
  5852.   XOR  DX, DX
  5853.   MOV  AX, ES:[DI]
  5854.  
  5855. @1:
  5856.  
  5857.   CMP  AX, ES:[DI]
  5858.   JE   @1
  5859.   MOV  AX, ES:[DI]
  5860.  
  5861. @2:
  5862.  
  5863.   CALL DelayOneMs
  5864.   INC  DX
  5865.   CMP  AX, ES:[DI]
  5866.   JE   @2
  5867.   MOV  DelayOfMS, DX
  5868.  
  5869. END;
  5870.  
  5871. {$ENDIF}
  5872.  
  5873. {────────────────────────────────────────────────────────────────────────────}
  5874.  
  5875. (*-
  5876.  
  5877. [FUNCTION]
  5878.  
  5879. Procedure DelLine;
  5880.  
  5881. [PARAMETERS]
  5882.  
  5883. (None)
  5884.  
  5885. [RETURNS]
  5886.  
  5887. (None)
  5888.  
  5889. [DESCRIPTION]
  5890.  
  5891. Deletes a Line at the Current Cursor Position.  If we are in a Window,
  5892. then the Deleted Line is just within this window.
  5893.  
  5894. Deletes the line that the cursor is currently on.  All lines
  5895. in the active window below the cursor will scroll up.
  5896.  
  5897. [SEE-ALSO]
  5898.  
  5899. [EXAMPLE]
  5900.  
  5901. -*)
  5902.  
  5903. Procedure DelLine;
  5904.  
  5905. BEGIN
  5906.  
  5907.   If TextAttr<>KnownTextAttr Then
  5908.     SyncAttr;
  5909.  
  5910.   If (WindMin<>KnownWindMin) or (WindMax<>KnownWindMax) Then
  5911.     SyncWind;
  5912.  
  5913.   VOutDelLine( CrtOCH );
  5914.  
  5915. END;  { DelLine }
  5916.  
  5917. {────────────────────────────────────────────────────────────────────────────}
  5918.  
  5919. (*-
  5920.  
  5921. [FUNCTION]
  5922.  
  5923. Procedure GotoXY(                       X       : BYTE;
  5924.                                         Y       : BYTE           );
  5925.  
  5926. [PARAMETERS]
  5927.  
  5928. X           X Screen Coordinate
  5929. Y           Y Screen Coordinate
  5930.  
  5931. [RETURNS]
  5932.  
  5933. (None)
  5934.  
  5935. [DESCRIPTION]
  5936.  
  5937. Moves the Cursor to the provided Screen Coordinates (Relative to any
  5938. active Window.
  5939.  
  5940. Hey, look.  Check out the normal CRT unit info for the rest
  5941. of these.  We'll fill them in soon.
  5942. We'll continue the comments with the other functions below
  5943. that are extensions to the normal CRT API.
  5944.  
  5945. [SEE-ALSO]
  5946.  
  5947. [EXAMPLE]
  5948.  
  5949. -*)
  5950.  
  5951. Procedure GotoXY(                       X       : BYTE;
  5952.                                         Y       : BYTE           );
  5953.  
  5954. BEGIN
  5955.  
  5956.   If (WindMin<>KnownWindMin) or (WindMax<>KnownWindMax) Then
  5957.     SyncWind;
  5958.  
  5959.   VOutGotoXY( CrtOCH, X,Y );
  5960.  
  5961. END;  { GotoXY }
  5962.  
  5963. {────────────────────────────────────────────────────────────────────────────}
  5964.  
  5965. (*-
  5966.  
  5967. [FUNCTION]
  5968.  
  5969. Procedure HighVideo;
  5970.  
  5971. [PARAMETERS]
  5972.  
  5973. (None)
  5974.  
  5975. [RETURNS]
  5976.  
  5977. (None)
  5978.  
  5979. [DESCRIPTION]
  5980.  
  5981. Sets the Vidio Intensity output to it's Highest Level.
  5982.  
  5983. [SEE-ALSO]
  5984.  
  5985. [EXAMPLE]
  5986.  
  5987. -*)
  5988.  
  5989. Procedure HighVideo;
  5990.  
  5991. BEGIN
  5992.  
  5993.   If TextAttr<>KnownTextAttr Then
  5994.     SyncAttr;
  5995.  
  5996.   { Set attribute }
  5997.  
  5998. END;  { HighVideo }
  5999.  
  6000. {────────────────────────────────────────────────────────────────────────────}
  6001.  
  6002. (*-
  6003.  
  6004. [FUNCTION]
  6005.  
  6006. Procedure InsLine;
  6007.  
  6008. [PARAMETERS]
  6009.  
  6010. (None)
  6011.  
  6012. [RETURNS]
  6013.  
  6014. (None)
  6015.  
  6016. [DESCRIPTION]
  6017.  
  6018. Inserts a Blank Line of the current Color Attributes at the Current
  6019. Cursor Position.  It we are in a Window, then the inserted Line is
  6020. just within this Window.
  6021.  
  6022. [SEE-ALSO]
  6023.  
  6024. [EXAMPLE]
  6025.  
  6026. -*)
  6027.  
  6028. Procedure InsLine;
  6029.  
  6030. BEGIN
  6031.  
  6032.   If (WindMin<>KnownWindMin) or (WindMax<>KnownWindMax) Then
  6033.     SyncWind;
  6034.  
  6035.   If TextAttr<>KnownTextAttr Then
  6036.     SyncAttr;
  6037.  
  6038.   VOutInsLine( CrtOCH );
  6039.  
  6040. END;  { InsLine }
  6041.  
  6042. {────────────────────────────────────────────────────────────────────────────}
  6043.  
  6044. (*-
  6045.  
  6046. [FUNCTION]
  6047.  
  6048. Function KeyPressed                                            : BOOLEAN;
  6049.  
  6050. [PARAMETERS]
  6051.  
  6052. (None)
  6053.  
  6054. [RETURNS]
  6055.  
  6056. Whether the Keyboard has been press since the last it was Read
  6057.  
  6058. [DESCRIPTION]
  6059.  
  6060. Determines if a Character is in the Keyboard Buffer and if so,
  6061. reports that ther is (TRUE).  If there isn't then the report
  6062. isn't (FALSE).
  6063.  
  6064. [SEE-ALSO]
  6065.  
  6066. [EXAMPLE]
  6067.  
  6068. -*)
  6069.  
  6070. Function KeyPressed                                            : BOOLEAN;
  6071.  
  6072. BEGIN
  6073.  
  6074.   KeyPressed := VInPressed;
  6075.  
  6076. END;  { KeyPressed }
  6077.  
  6078. {────────────────────────────────────────────────────────────────────────────}
  6079.  
  6080. (*-
  6081.  
  6082. [FUNCTION]
  6083.  
  6084. Procedure LowVideo;
  6085.  
  6086. [PARAMETERS]
  6087.  
  6088. (None)
  6089.  
  6090. [RETURNS]
  6091.  
  6092. (None)
  6093.  
  6094. [DESCRIPTION]
  6095.  
  6096. Sets the Vidio Intensity output to it's Lowest Level.
  6097.  
  6098. [SEE-ALSO]
  6099.  
  6100. [EXAMPLE]
  6101.  
  6102. -*)
  6103.  
  6104. Procedure LowVideo;
  6105.  
  6106. BEGIN
  6107.  
  6108.   If TextAttr<>KnownTextAttr Then
  6109.     SyncAttr;
  6110.  
  6111.   { Set attribute }
  6112.  
  6113. END;  { LowVideo }
  6114.  
  6115. {────────────────────────────────────────────────────────────────────────────}
  6116.  
  6117. (*-
  6118.  
  6119. [FUNCTION]
  6120.  
  6121. Procedure NormVideo;
  6122.  
  6123. [PARAMETERS]
  6124.  
  6125. (None)
  6126.  
  6127. [RETURNS]
  6128.  
  6129. (None)
  6130.  
  6131. [DESCRIPTION]
  6132.  
  6133. Resets the Video Intensity output to the Normal Level.
  6134.  
  6135. [SEE-ALSO]
  6136.  
  6137. [EXAMPLE]
  6138.  
  6139. -*)
  6140.  
  6141. Procedure NormVideo;
  6142.  
  6143. BEGIN
  6144.  
  6145.   If TextAttr<>KnownTextAttr Then
  6146.     SyncAttr;
  6147.  
  6148. END;  { NormVideo }
  6149.  
  6150. {────────────────────────────────────────────────────────────────────────────}
  6151.  
  6152. (*-
  6153.  
  6154. [FUNCTION]
  6155.  
  6156. Procedure NoSound;
  6157.  
  6158. [PARAMETERS]
  6159.  
  6160. (None)
  6161.  
  6162. [RETURNS]
  6163.  
  6164. (None)
  6165.  
  6166. [DESCRIPTION]
  6167.  
  6168. Turns off any audio output from the Speaker.
  6169.  
  6170. [SEE-ALSO]
  6171.  
  6172. [EXAMPLE]
  6173.  
  6174. -*)
  6175.  
  6176. Procedure NoSound;
  6177.  
  6178. Assembler;
  6179. ASM
  6180.  
  6181.   IN  AL, $61
  6182.   AND AL, $FC
  6183.   OUT $61, AL
  6184.  
  6185. END;  { NoSound }
  6186.  
  6187. {────────────────────────────────────────────────────────────────────────────}
  6188.  
  6189. (*-
  6190.  
  6191. [FUNCTION]
  6192.  
  6193. Function  ReadKey                                              : CHAR;
  6194.  
  6195. [PARAMETERS]
  6196.  
  6197. (None)
  6198.  
  6199. [RETURNS]
  6200.  
  6201. 1st available Character Read from the Keyboard
  6202.  
  6203. [DESCRIPTION]
  6204.  
  6205. Reads a Key from the keyboard and returns the 1st Character Read.
  6206.  
  6207. [SEE-ALSO]
  6208.  
  6209. [EXAMPLE]
  6210.  
  6211. -*)
  6212.  
  6213. Function  ReadKey                                              : CHAR;
  6214.  
  6215. BEGIN
  6216.  
  6217.   ReadKey := VInRead;
  6218.  
  6219. END; { ReadKey }
  6220.  
  6221. {────────────────────────────────────────────────────────────────────────────}
  6222.  
  6223. (*-
  6224.  
  6225. [FUNCTION]
  6226.  
  6227. Procedure Sound(                  Hz             : WORD      );
  6228.  
  6229. [PARAMETERS]
  6230.  
  6231. Hz          Desired Audio Frequency in Hertz
  6232.  
  6233. [RETURNS]
  6234.  
  6235. (None)
  6236.  
  6237. [DESCRIPTION]
  6238.  
  6239. Outputs a sound thru the speaker at the provided Frequency.
  6240.  
  6241. [SEE-ALSO]
  6242.  
  6243. [EXAMPLE]
  6244.  
  6245. -*)
  6246.  
  6247. Procedure Sound(                  Hz             : WORD      );
  6248.  
  6249. Assembler;
  6250. ASM
  6251.  
  6252.   MOV  BX, Hz
  6253.   MOV  AX, 34DDh
  6254.   MOV  DX, 0012h
  6255.   CMP  DX, BX
  6256.   JNC  @2
  6257.   DIV  BX
  6258.   MOV  BX, AX
  6259.   IN   AL, 61h
  6260.   TEST AL, 3
  6261.   JNZ  @1
  6262.   OR   AL, 3
  6263.   OUT  61h, AL
  6264.   MOV  AL, 0B6h
  6265.   OUT  43H, AL
  6266.  
  6267. @1:
  6268.  
  6269.   MOV  AL, BL
  6270.   OUT  42h, AL
  6271.   MOV  AL, BH
  6272.   OUT  42H, AL
  6273.  
  6274. @2:
  6275.  
  6276. END;  { Sound }
  6277.  
  6278. {────────────────────────────────────────────────────────────────────────────}
  6279.  
  6280. (*-
  6281.  
  6282. [FUNCTION]
  6283.  
  6284. Procedure TextBackGround(         Color          : BYTE      );
  6285.  
  6286. [PARAMETERS]
  6287.  
  6288. Color       New Text Background Color
  6289.  
  6290. [RETURNS]
  6291.  
  6292. (None)
  6293.  
  6294. [DESCRIPTION]
  6295.  
  6296. Sets the New Active Text Background Color
  6297.  
  6298. [SEE-ALSO]
  6299.  
  6300. [EXAMPLE]
  6301.  
  6302. -*)
  6303.  
  6304. Procedure TextBackGround(         Color          : BYTE      );
  6305.  
  6306. BEGIN
  6307.  
  6308.   { may need to syncattr }
  6309.  
  6310.   VOutTextBackGround( CrtOCH, Color AND $07 );
  6311.  
  6312.   TextAttrSet( (TextAttr AND $8F) + ((Color AND $07) SHL 4) );
  6313.  
  6314. END;  { TextBackGround }
  6315.  
  6316. {────────────────────────────────────────────────────────────────────────────}
  6317.  
  6318. (*-
  6319.  
  6320. [FUNCTION]
  6321.  
  6322. Procedure TextColor(              Color          : BYTE      );
  6323.  
  6324. [PARAMETERS]
  6325.  
  6326. Color       New Text Foreground Color
  6327.  
  6328. [RETURNS]
  6329.  
  6330. (None)
  6331.  
  6332. [DESCRIPTION]
  6333.  
  6334. Sets the New Active Text Foreground Color
  6335.  
  6336. [SEE-ALSO]
  6337.  
  6338. [EXAMPLE]
  6339.  
  6340. -*)
  6341.  
  6342. Procedure TextColor(              Color          : BYTE      );
  6343.  
  6344. BEGIN
  6345.  
  6346.   { may need to sync attr }
  6347.  
  6348.   VOutTextColor( CrtOCH, Color );
  6349.  
  6350.   TextAttrSet( (TextAttr and $F0) + ((Color and $0F)) );
  6351.  
  6352. END;  { TextColor }
  6353.  
  6354. {────────────────────────────────────────────────────────────────────────────}
  6355.  
  6356. (*-
  6357.  
  6358. [FUNCTION]
  6359.  
  6360. Procedure TextMode(               Mode           : INTEGER   );
  6361.  
  6362. [PARAMETERS]
  6363.  
  6364. Mode        Desired CRT Vidio Mode
  6365.  
  6366. [RETURNS]
  6367.  
  6368. (None)
  6369.  
  6370. [DESCRIPTION]
  6371.  
  6372. [SEE-ALSO]
  6373.  
  6374. [EXAMPLE]
  6375.  
  6376. -*)
  6377.  
  6378. Procedure TextMode(               Mode           : INTEGER   );
  6379.  
  6380. BEGIN
  6381.  
  6382.   { set text mode }
  6383.  
  6384. END;  { TextMode }
  6385.  
  6386. {────────────────────────────────────────────────────────────────────────────}
  6387.  
  6388. (*-
  6389.  
  6390. [FUNCTION]
  6391.  
  6392. Function  WhereX                                               : BYTE;
  6393.  
  6394. [PARAMETERS]
  6395.  
  6396. (None)
  6397.  
  6398. [RETURNS]
  6399.  
  6400. The Current X Cursor Position
  6401.  
  6402. [DESCRIPTION]
  6403.  
  6404. Determines and returns the Current X Cursor Screen Coordinates.
  6405.  
  6406. [SEE-ALSO]
  6407.  
  6408. [EXAMPLE]
  6409.  
  6410. -*)
  6411.  
  6412. Function  WhereX                                               : BYTE;
  6413.  
  6414. BEGIN
  6415.  
  6416.   WhereX := VOutWhereX( CrtOCH );
  6417.  
  6418. END;  { Where X }
  6419.  
  6420. {────────────────────────────────────────────────────────────────────────────}
  6421.  
  6422. (*-
  6423.  
  6424. [FUNCTION]
  6425.  
  6426. Function  WhereY                                              : BYTE;
  6427.  
  6428. [PARAMETERS]
  6429.  
  6430. (None)
  6431.  
  6432. [RETURNS]
  6433.  
  6434. The Current Y Cursor Position
  6435.  
  6436. [DESCRIPTION]
  6437.  
  6438. Determines and returns the Current Y Cursor Screen Coordinates.
  6439.  
  6440. [SEE-ALSO]
  6441.  
  6442. [EXAMPLE]
  6443.  
  6444. -*)
  6445.  
  6446. Function  WhereY                                               : BYTE;
  6447.  
  6448. BEGIN
  6449.  
  6450.   WhereY := VOutWhereY( CrtOCH );
  6451.  
  6452. END;  { WhereY }
  6453.  
  6454. {────────────────────────────────────────────────────────────────────────────}
  6455.  
  6456. (*-
  6457.  
  6458. [FUNCTION]
  6459.  
  6460. Procedure Window(                 X1             : BYTE;
  6461.                                   Y1             : BYTE;
  6462.                                   X2             : BYTE;
  6463.                                   Y2             : BYTE      );
  6464.  
  6465. [PARAMETERS]
  6466.  
  6467. X1          Left Window Coordinate
  6468. Y1          Top Window Coordinate
  6469. X2          Right Window Coordinate
  6470. Y2          Bottom Window Coordinate
  6471.  
  6472. [RETURNS]
  6473.  
  6474. (None)
  6475.  
  6476. [DESCRIPTION]
  6477.  
  6478. Establishes a Window with the provided Coordinates.
  6479.  
  6480. [SEE-ALSO]
  6481.  
  6482. [EXAMPLE]
  6483.  
  6484. -*)
  6485.  
  6486. Procedure Window(                 X1             : BYTE;
  6487.                                   Y1             : BYTE;
  6488.                                   X2             : BYTE;
  6489.                                   Y2             : BYTE      );
  6490.  
  6491. BEGIN
  6492.  
  6493.   VOutWindow( CrtOCH, X1, Y1, X2, Y2 );
  6494.  
  6495.   WindMin := ((Y1-1) SHL 8) + (X1-1);
  6496.   WindMax := ((Y2-1) SHL 8) + (X2-1);
  6497.  
  6498.   KnownWindMin := WindMin;
  6499.   KnownWindMax := WindMax;
  6500.  
  6501.   WindCenterCol := X1 + ((X2-X1) DIV 2);
  6502.   WindCenterRow := Y1 + ((Y2-Y1) DIV 2);
  6503.  
  6504. END;  { Window }
  6505.  
  6506. {────────────────────────────────────────────────────────────────────────────}
  6507.  
  6508. (*-
  6509.  
  6510. [FUNCTION]
  6511.  
  6512. Procedure WindowScreen;
  6513.  
  6514. [PARAMETERS]
  6515.  
  6516. (None)
  6517.  
  6518. [RETURNS]
  6519.  
  6520. (None)
  6521.  
  6522. [DESCRIPTION]
  6523.  
  6524. Restores the Window Size as that of the Entire Screen.
  6525.  
  6526. Sets the active window size to be the entire screen.
  6527.  
  6528. [SEE-ALSO]
  6529.  
  6530. [EXAMPLE]
  6531.  
  6532. -*)
  6533.  
  6534. Procedure WindowScreen;
  6535.  
  6536. BEGIN
  6537.  
  6538.   VOutWindow( CrtOCH, 1,1,ScreenCols,ScreenRows );
  6539.  
  6540. END;  { WindowScreen }
  6541.  
  6542. {────────────────────────────────────────────────────────────────────────────}
  6543.  
  6544. (*-
  6545.  
  6546. [FUNCTION]
  6547.  
  6548. Function TextColorGet                                          : BYTE;
  6549.  
  6550. [PARAMETERS]
  6551.  
  6552. (None)
  6553.  
  6554. [RETURNS]
  6555.  
  6556. The Current Foreground Attribute Color
  6557.  
  6558. [DESCRIPTION]
  6559.  
  6560. Returns the Current Foreground Color from the CRT Attribute Value.
  6561.  
  6562. Gets the current text color.  IT IS PREFERED TO USE THIS
  6563. INSTEAD OF JUST LOOKING AT THE TEXTATTR VARIABLE.
  6564.  
  6565. [SEE-ALSO]
  6566.  
  6567. [EXAMPLE]
  6568.  
  6569. -*)
  6570.  
  6571. Function TextColorGet                                          : BYTE;
  6572.  
  6573. BEGIN
  6574.  
  6575.   TextColorGet := TextAttr AND $0F;
  6576.  
  6577. END;  { TextColorGet }
  6578.  
  6579. {────────────────────────────────────────────────────────────────────────────}
  6580.  
  6581. (*-
  6582.  
  6583. [FUNCTION]
  6584.  
  6585. Function TextBackgroundGet                                     : BYTE;
  6586.  
  6587. [PARAMETERS]
  6588.  
  6589. (None)
  6590.  
  6591. [RETURNS]
  6592.  
  6593. The Current Background Attribute Color
  6594.  
  6595. [DESCRIPTION]
  6596.  
  6597. Returns the Current Background Color from the CRT Attribute
  6598. Value.
  6599.  
  6600. Gets the current text background. see note on TextColorGet.
  6601.  
  6602. [SEE-ALSO]
  6603.  
  6604. [EXAMPLE]
  6605.  
  6606. -*)
  6607.  
  6608. Function TextBackgroundGet                                     : BYTE;
  6609.  
  6610. BEGIN
  6611.  
  6612.   TextBackGroundGet := (TextAttr AND $70) SHR 4;
  6613.  
  6614. END;  { TextBackgroundGet }
  6615.  
  6616. {────────────────────────────────────────────────────────────────────────────}
  6617.  
  6618. (*-
  6619.  
  6620. [FUNCTION]
  6621.  
  6622. Procedure TextColors(             Fore           : BYTE;
  6623.                                   Back           : BYTE      );
  6624.  
  6625. [PARAMETERS]
  6626.  
  6627. fore        foreground color to use
  6628. back        background color to use
  6629.  
  6630. [RETURNS]
  6631.  
  6632. (None)
  6633.  
  6634. [DESCRIPTION]
  6635.  
  6636. Sets the Current CRT Attribute to the foreground and background
  6637. colors provided.
  6638.  
  6639. [SEE-ALSO]
  6640.  
  6641. [EXAMPLE]
  6642.  
  6643. -*)
  6644.  
  6645.  
  6646. Procedure TextColors(             Fore           : BYTE;
  6647.                                   Back           : BYTE      );
  6648.  
  6649. BEGIN
  6650.  
  6651.   TextColor( Fore );
  6652.   TextBackGround( Back );
  6653.  
  6654. END;
  6655.  
  6656.  
  6657. (*-
  6658.  
  6659. [FUNCTION]
  6660.  
  6661. Procedure TextAttrSet(            Attr           : BYTE      );
  6662.  
  6663. [PARAMETERS]
  6664.  
  6665. Attr        New Attribute
  6666.  
  6667. [RETURNS]
  6668.  
  6669. (None)
  6670.  
  6671. [DESCRIPTION]
  6672.  
  6673. Sets the Current CRT Attribute to the Attribute Provided.
  6674.  
  6675. Sets the current TextAttr.  IT IS PREFERED THAT ONE USE THIS
  6676. INSTEAD OF DIRECTLY CHANGING THE TEXTATTR VARIABLE.
  6677.  
  6678. [SEE-ALSO]
  6679.  
  6680. [EXAMPLE]
  6681.  
  6682. -*)
  6683.  
  6684. Procedure TextAttrSet(            Attr           : BYTE      );
  6685.  
  6686. BEGIN
  6687.  
  6688.   VOutTextAttrSet( CrtOCH, CRTColorMap[ Attr ] );
  6689.  
  6690.   KnownTextAttr := CRTColorMap[ Attr ];
  6691.  
  6692.   TextAttr := KnownTextAttr;
  6693.  
  6694. END;  { TextAttrSet }
  6695.  
  6696. {────────────────────────────────────────────────────────────────────────────}
  6697.  
  6698. (*-
  6699.  
  6700. [FUNCTION]
  6701.  
  6702. Procedure GotoX(                  X              : BYTE      );
  6703.  
  6704. [PARAMETERS]
  6705.  
  6706. X           column to go to
  6707.  
  6708. [RETURNS]
  6709.  
  6710. (None)
  6711.  
  6712. [DESCRIPTION]
  6713.  
  6714. Moves the Cursor the specifed column on the current line.
  6715.  
  6716. [SEE-ALSO]
  6717.  
  6718. [EXAMPLE]
  6719.  
  6720. -*)
  6721.  
  6722.  
  6723. Procedure GotoX(                  X              : BYTE      );
  6724.  
  6725. BEGIN
  6726.  
  6727.   GotoXY( X, WhereY );
  6728.  
  6729. END;
  6730.  
  6731.  
  6732. {────────────────────────────────────────────────────────────────────────────}
  6733.  
  6734. (*-
  6735.  
  6736. [FUNCTION]
  6737.  
  6738. Procedure GotoY(                  Y              : BYTE      );
  6739.  
  6740. [PARAMETERS]
  6741.  
  6742. X           row/line to go to
  6743.  
  6744. [RETURNS]
  6745.  
  6746. (None)
  6747.  
  6748. [DESCRIPTION]
  6749.  
  6750. Moves the Cursor the specifed row/line on the in the current column.
  6751.  
  6752. [SEE-ALSO]
  6753.  
  6754. [EXAMPLE]
  6755.  
  6756. -*)
  6757.  
  6758.  
  6759. Procedure GotoY(                  Y              : BYTE      );
  6760.  
  6761. BEGIN
  6762.  
  6763.   GotoXY( WhereX, Y );
  6764.  
  6765. END;
  6766.  
  6767. {────────────────────────────────────────────────────────────────────────────}
  6768.  
  6769. (*-
  6770.  
  6771. [FUNCTION]
  6772.  
  6773. Procedure CursorUp(               Count          : BYTE      );
  6774.  
  6775. [PARAMETERS]
  6776.  
  6777. Count       Number of Lines to Move Up
  6778.  
  6779. [RETURNS]
  6780.  
  6781. (None)
  6782.  
  6783. [DESCRIPTION]
  6784.  
  6785. Moves the Cursor Up by a given number of Lines.
  6786.  
  6787. [SEE-ALSO]
  6788.  
  6789. [EXAMPLE]
  6790.  
  6791. -*)
  6792.  
  6793. Procedure CursorUp(               Count          : BYTE      );
  6794.  
  6795. BEGIN
  6796.  
  6797.   VOutCursorUp( CrtOCH, Count );
  6798.  
  6799. END; { CursorUp }
  6800.  
  6801. {────────────────────────────────────────────────────────────────────────────}
  6802.  
  6803. (*-
  6804.  
  6805. [FUNCTION]
  6806.  
  6807. Procedure CursorDown(             Count          : BYTE      );
  6808.  
  6809. [PARAMETERS]
  6810.  
  6811. Count       Number of Lines to Move Down
  6812.  
  6813. [RETURNS]
  6814.  
  6815. (None)
  6816.  
  6817. [DESCRIPTION]
  6818.  
  6819. Moves the Cursor Down by a given number of Lines.
  6820.  
  6821. [SEE-ALSO]
  6822.  
  6823. [EXAMPLE]
  6824.  
  6825. -*)
  6826.  
  6827. Procedure CursorDown(             Count          : BYTE      );
  6828.  
  6829. BEGIN
  6830.  
  6831.   VOutCursorDown( CrtOCH, Count );
  6832.  
  6833. END;  { CursorDown }
  6834.  
  6835. {────────────────────────────────────────────────────────────────────────────}
  6836.  
  6837. (*-
  6838.  
  6839. [FUNCTION]
  6840.  
  6841. Procedure CursorLeft(             Count          : BYTE      );
  6842.  
  6843. [PARAMETERS]
  6844.  
  6845. Count       Number of Places to Space Left
  6846.  
  6847. [RETURNS]
  6848.  
  6849. (None)
  6850.  
  6851. [DESCRIPTION]
  6852.  
  6853. Moves the Cursor Left by a given number of Places.
  6854.  
  6855. [SEE-ALSO]
  6856.  
  6857. [EXAMPLE]
  6858.  
  6859. -*)
  6860.  
  6861. Procedure CursorLeft(             Count          : BYTE      );
  6862.  
  6863. BEGIN
  6864.  
  6865.   VOutCursorLeft( CrtOCH, Count );
  6866.  
  6867. END;  { CursorLeft }
  6868.  
  6869. {────────────────────────────────────────────────────────────────────────────}
  6870.  
  6871. (*-
  6872.  
  6873. [FUNCTION]
  6874.  
  6875. Procedure CursorRight(            Count          : BYTE      );
  6876.  
  6877. [PARAMETERS]
  6878.  
  6879. Count       Number of Places to Spaces Right
  6880.  
  6881. [RETURNS]
  6882.  
  6883. (None)
  6884.  
  6885. [DESCRIPTION]
  6886.  
  6887. Moves the Cursor Right by a given number of Places.
  6888.  
  6889. [SEE-ALSO]
  6890.  
  6891. [EXAMPLE]
  6892.  
  6893. -*)
  6894.  
  6895. Procedure CursorRight(            Count          : BYTE      );
  6896.  
  6897. BEGIN
  6898.  
  6899.   VOutCursorRight( CrtOCH, Count );
  6900.  
  6901. END;  { CursorRight }
  6902.  
  6903. {────────────────────────────────────────────────────────────────────────────}
  6904.  
  6905. (*-
  6906.  
  6907. [FUNCTION]
  6908.  
  6909. Function CharRead(                X1             : BYTE;
  6910.                                   Y1             : BYTE      ) : CHAR;
  6911.  
  6912. [PARAMETERS]
  6913.  
  6914. X1          X Screen Coordinate
  6915. Y1          Y Screen Coordinate
  6916.  
  6917. [RETURNS]
  6918.  
  6919. Character Read from the Screen Coordinates
  6920.  
  6921. [DESCRIPTION]
  6922.  
  6923. Reads a Character from the Screen at the provided Coordinates.
  6924.  
  6925. Reads a character from the display console.  returns whatever
  6926. character is on the screen at the specified location.
  6927.  
  6928. [SEE-ALSO]
  6929.  
  6930. [EXAMPLE]
  6931.  
  6932. -*)
  6933.  
  6934. Function CharRead(                X1             : BYTE;
  6935.                                   Y1             : BYTE      ) : CHAR;
  6936.  
  6937. BEGIN
  6938.  
  6939.   CharRead := VOutCharRead( CrtOCH, X1,Y1 );
  6940.  
  6941. END;  { CharRead }
  6942.  
  6943. {────────────────────────────────────────────────────────────────────────────}
  6944.  
  6945. (*-
  6946.  
  6947. [FUNCTION]
  6948.  
  6949. Function AttrRead(                X1             : BYTE;
  6950.                                   Y1             : BYTE      ) : BYTE;
  6951.  
  6952. [PARAMETERS]
  6953.  
  6954. X1          X Screen Coordinate
  6955. Y1          Y Screen Coordinate
  6956.  
  6957. [RETURNS]
  6958.  
  6959. Attribute Read from the Screen Coordinates
  6960.  
  6961. [DESCRIPTION]
  6962.  
  6963. Reads an Attribute from the Screen at the provided Coordinates.
  6964.  
  6965. Reads a attribute from the display console.  returns whatever
  6966. attribute is on the screen at the specified location.
  6967.  
  6968. [SEE-ALSO]
  6969.  
  6970. [EXAMPLE]
  6971.  
  6972. -*)
  6973.  
  6974. Function AttrRead(                X1             : BYTE;
  6975.                                   Y1             : BYTE      ) : BYTE;
  6976.  
  6977. BEGIN
  6978.  
  6979.   AttrRead := VOutAttrRead( CrtOCH, X1,Y1 );
  6980.  
  6981. END; { AttrRead }
  6982.  
  6983. {────────────────────────────────────────────────────────────────────────────}
  6984.  
  6985. (*-
  6986.  
  6987. [FUNCTION]
  6988.  
  6989. Procedure AttrWrite(              X1             : BYTE;
  6990.                                   Y1             : BYTE;
  6991.                                   Attr           : BYTE      );
  6992.  
  6993. [PARAMETERS]
  6994.  
  6995. X1          X Screen Coordinate
  6996. Y1          Y Screen Coordinate
  6997. Attr        Attribute to Write
  6998.  
  6999. [RETURNS]
  7000.  
  7001. (None)
  7002.  
  7003. [DESCRIPTION]
  7004.  
  7005. Writes a given Attribute at a provided Screen Coordinate.
  7006.  
  7007. Writes an attribute to the display console.
  7008.  
  7009. [SEE-ALSO]
  7010.  
  7011. [EXAMPLE]
  7012.  
  7013. -*)
  7014.  
  7015. Procedure AttrWrite(              X1             : BYTE;
  7016.                                   Y1             : BYTE;
  7017.                                   Attr           : BYTE      );
  7018.  
  7019. BEGIN
  7020.  
  7021.   VOutAttrWrite( CrtOCH, X1, Y1, Attr );
  7022.  
  7023. END; { AttrWrite }
  7024.  
  7025. {────────────────────────────────────────────────────────────────────────────}
  7026.  
  7027. (*-
  7028.  
  7029. [FUNCTION]
  7030.  
  7031. Function  RegionMemQuery(         X1             : BYTE;
  7032.                                   Y1             : BYTE;
  7033.                                   X2             : BYTE;
  7034.                                   Y2             : BYTE      ) : WORD;
  7035.  
  7036. [PARAMETERS]
  7037.  
  7038. X1          Left Region Coordinate
  7039. Y1          Top Region Coordinate
  7040. X2          Right Region Coordinate
  7041. Y2          Bottom Region Coordinate
  7042.  
  7043. [RETURNS]
  7044.  
  7045. Number of Bytes of Memory required to Store Region
  7046.  
  7047. [DESCRIPTION]
  7048.  
  7049. Calculates and returns the number of bytes required to store a
  7050. given Region.
  7051.  
  7052. Returns how many bytes of memory need to be allocated to store
  7053. the specified region of the display console.
  7054.  
  7055. [SEE-ALSO]
  7056.  
  7057. [EXAMPLE]
  7058.  
  7059. -*)
  7060.  
  7061. Function  RegionMemQuery(         X1             : BYTE;
  7062.                                   Y1             : BYTE;
  7063.                                   X2             : BYTE;
  7064.                                   Y2             : BYTE      ) : WORD;
  7065.  
  7066. BEGIN
  7067.  
  7068.   RegionMemQuery := VOutQueryRegion( CrtOCH, x1,y1,x2,y2 );
  7069.  
  7070. END;  { RegionMemQuery }
  7071.  
  7072. {────────────────────────────────────────────────────────────────────────────}
  7073.  
  7074. (*-
  7075.  
  7076. [FUNCTION]
  7077.  
  7078. Procedure RegionScrollUp(         X1             : BYTE;
  7079.                                   Y1             : BYTE;
  7080.                                   X2             : BYTE;
  7081.                                   Y2             : BYTE;
  7082.                                   Count          : BYTE      );
  7083.  
  7084. [PARAMETERS]
  7085.  
  7086. X1          Left Screen Region Coordinate
  7087. Y1          Top Screen Region Coordinate
  7088. X2          Right Screen Region Coordinate
  7089. Y2          Bottom Screen Region Coordinate
  7090. Count       Number of Lines to Scroll
  7091.  
  7092. [RETURNS]
  7093.  
  7094. (None)
  7095.  
  7096. [DESCRIPTION]
  7097.  
  7098. Scrolls the Designated Screen Region Up by a given number of Lines.
  7099.  
  7100. Returns how many bytes of memory need to be allocated to store
  7101. the specified region of the display console.
  7102.  
  7103. [SEE-ALSO]
  7104.  
  7105. [EXAMPLE]
  7106.  
  7107. -*)
  7108.  
  7109. Procedure RegionScrollUp(         X1             : BYTE;
  7110.                                   Y1             : BYTE;
  7111.                                   X2             : BYTE;
  7112.                                   Y2             : BYTE;
  7113.                                   Count          : BYTE      );
  7114.  
  7115. BEGIN
  7116.  
  7117. END;  { RegionScrollUp }
  7118.  
  7119. {────────────────────────────────────────────────────────────────────────────}
  7120.  
  7121. (*-
  7122.  
  7123. [FUNCTION]
  7124.  
  7125. Procedure RegionScrollDown(       X1             : BYTE;
  7126.                                   Y1             : BYTE;
  7127.                                   X2             : BYTE;
  7128.                                   Y2             : BYTE;
  7129.                                   Count          : BYTE      );
  7130.  
  7131. [PARAMETERS]
  7132.  
  7133. X1          Left Screen Region Coordinate
  7134. Y1          Top Screen Region Coordinate
  7135. X2          Right Screen Region Coordinate
  7136. Y2          Bottom Screen Region Coordinate
  7137. Count       Number of Lines to Scroll
  7138.  
  7139. [RETURNS]
  7140.  
  7141. (None)
  7142.  
  7143. [DESCRIPTION]
  7144.  
  7145. Scrolls the Designated Screen Region Down by a given number of Lines.
  7146.  
  7147. Scrolls the specified region down by "count" number of lines.
  7148.  
  7149. [SEE-ALSO]
  7150.  
  7151. [EXAMPLE]
  7152.  
  7153. -*)
  7154.  
  7155. Procedure RegionScrollDown(       X1             : BYTE;
  7156.                                   Y1             : BYTE;
  7157.                                   X2             : BYTE;
  7158.                                   Y2             : BYTE;
  7159.                                   Count          : BYTE      );
  7160.  
  7161. BEGIN
  7162.  
  7163. END;  { RegionScrollDown }
  7164.  
  7165. {────────────────────────────────────────────────────────────────────────────}
  7166.  
  7167. (*-
  7168.  
  7169. [FUNCTION]
  7170.  
  7171. Procedure RegionRead(             X1             : BYTE;
  7172.                                   Y1             : BYTE;
  7173.                                   X2             : BYTE;
  7174.                                   Y2             : BYTE;
  7175.                                   Region         : Pointer   );
  7176.  
  7177. [PARAMETERS]
  7178.  
  7179. X1          Source Left Screen Region Coordinate
  7180. Y1          Source Top Screen Region Coordinate
  7181. X2          Source Right Region Screen Region Coordinate
  7182. Y2          Source Bottom Screen Region Coordinate
  7183. Region      Pointer to Region Data Storage Area
  7184.  
  7185. [RETURNS]
  7186.  
  7187. (None)
  7188.  
  7189. [DESCRIPTION]
  7190.  
  7191. [SEE-ALSO]
  7192.  
  7193. [EXAMPLE]
  7194.  
  7195. -*)
  7196.  
  7197. Procedure RegionRead(             X1             : BYTE;
  7198.                                   Y1             : BYTE;
  7199.                                   X2             : BYTE;
  7200.                                   Y2             : BYTE;
  7201.                                   Region         : Pointer   );
  7202.  
  7203. BEGIN
  7204.  
  7205.   VOutReadRegion( CrtOCH, X1,Y1,X2,Y2, Region );
  7206.  
  7207. END;  { RegionRead }
  7208.  
  7209. {────────────────────────────────────────────────────────────────────────────}
  7210.  
  7211. (*-
  7212.  
  7213. [FUNCTION]
  7214.  
  7215. Procedure RegionWrite(            X1             : BYTE;
  7216.                                   Y1             : BYTE;
  7217.                                   X2             : BYTE;
  7218.                                   Y2             : BYTE;
  7219.                                   Region         : Pointer   );
  7220.  
  7221. [PARAMETERS]
  7222.  
  7223. X1          Destination Left Screen Region Coordinate
  7224. Y1          Destination Top Screen Region Coordinate
  7225. X2          Destination Right Region Screen Region Coordinate
  7226. Y2          Destination Bottom Screen Region Coordinate
  7227. Region      Pointer to Region Data
  7228.  
  7229. [RETURNS]
  7230.  
  7231. (None)
  7232.  
  7233. [DESCRIPTION]
  7234.  
  7235. [SEE-ALSO]
  7236.  
  7237. [EXAMPLE]
  7238.  
  7239. -*)
  7240.  
  7241. Procedure RegionWrite(            X1             : BYTE;
  7242.                                   Y1             : BYTE;
  7243.                                   X2             : BYTE;
  7244.                                   Y2             : BYTE;
  7245.                                   Region         : Pointer   );
  7246.  
  7247. BEGIN
  7248.  
  7249.   VOutWriteRegion( CrtOCH, X1,Y1,X2,Y2, Region );
  7250.  
  7251. END; { RegionWrite }
  7252.  
  7253. {────────────────────────────────────────────────────────────────────────────}
  7254.  
  7255. (*-
  7256.  
  7257. [FUNCTION]
  7258.  
  7259. Procedure RegionCopy(             X1             : BYTE;
  7260.                                   Y1             : BYTE
  7261.                                   X2             : BYTE;
  7262.                                   Y2             : BYTE;
  7263.                                   ToX1           : BYTE;
  7264.                                   ToY1           : BYTE      );
  7265.  
  7266. [PARAMETERS]
  7267.  
  7268. X1          Source Left Screen Region Coordinate
  7269. Y1          Source Top Screen Region Coordinate
  7270. X2          Source Right Region Screen Region Coordinate
  7271. Y2          Source Bottom Screen Region Coordinate
  7272. ToX1        Destination Left Screen Region Coordinate
  7273. ToY1        Destination Top Screen Region Coordinate
  7274.  
  7275. [RETURNS]
  7276.  
  7277. [DESCRIPTION]
  7278.  
  7279. Writes a region store buffer to the specified screen locations.
  7280.  
  7281. [SEE-ALSO]
  7282.  
  7283. [EXAMPLE]
  7284.  
  7285. -*)
  7286.  
  7287. Procedure RegionCopy(             X1             : BYTE;
  7288.                                   Y1             : BYTE;
  7289.                                   X2             : BYTE;
  7290.                                   Y2             : BYTE;
  7291.                                   ToX1           : BYTE;
  7292.                                   ToY1           : BYTE      );
  7293.  
  7294. BEGIN
  7295.  
  7296. END;
  7297.  
  7298. {────────────────────────────────────────────────────────────────────────────}
  7299.  
  7300. (*-
  7301.  
  7302. [FUNCTION]
  7303.  
  7304. Procedure RegionFill(             X1             : BYTE;
  7305.                                   Y1             : BYTE;
  7306.                                   X2             : BYTE;
  7307.                                   Y2             : BYTE;
  7308.                                   Ch             : CHAR;
  7309.                                   F              : BYTE;
  7310.                                   B              : BYTE      );
  7311.  
  7312. [PARAMETERS]
  7313.  
  7314. X1          Left Screen Region Coordinate
  7315. Y1          Top Screen Region Coordinate
  7316. X2          Right Region Screen Region Coordinate
  7317. Y2          Bottom Screen Region Coordinate
  7318. Ch          Character Pattern to Fill Region With
  7319. F           Foreground Color to Fill Region With
  7320. B           Background Color to Fill Region With
  7321.  
  7322. [RETURNS]
  7323.  
  7324. (None)
  7325.  
  7326. [DESCRIPTION]
  7327.  
  7328. Fills the specified region with the specified "Ch" aracter,
  7329. "F"oreground, and "B"ackground.
  7330.  
  7331. [SEE-ALSO]
  7332.  
  7333. [EXAMPLE]
  7334.  
  7335. -*)
  7336.  
  7337. Procedure RegionFill(             X1             : BYTE;
  7338.                                   Y1             : BYTE;
  7339.                                   X2             : BYTE;
  7340.                                   Y2             : BYTE;
  7341.                                   Ch             : CHAR;
  7342.                                   F              : BYTE;
  7343.                                   B              : BYTE      );
  7344.  
  7345. BEGIN
  7346.  
  7347.    VOutFillRegion( CrtOCH, X1, Y1, X2, Y2, ((B AND $07) shl 4) + F, CH );
  7348.  
  7349. END;  { RegionFill }
  7350.  
  7351. {────────────────────────────────────────────────────────────────────────────}
  7352.  
  7353. (*-
  7354.  
  7355. [FUNCTION]
  7356.  
  7357. Procedure RegionFillAttr(         X1             : BYTE;
  7358.                                   Y1             : BYTE;
  7359.                                   X2             : BYTE;
  7360.                                   Y2             : BYTE;
  7361.                                   Attr           : BYTE      );
  7362.  
  7363. [PARAMETERS]
  7364.  
  7365. X1          Left Screen Region Coordinate
  7366. Y1          Top Screen Region Coordinate
  7367. X2          Right Region Screen Region Coordinate
  7368. Y2          Bottom Screen Region Coordinate
  7369. Attr        Color attribute to use
  7370.  
  7371. [RETURNS]
  7372.  
  7373. (None)
  7374.  
  7375. [DESCRIPTION]
  7376.  
  7377. Fills the specified region with the specified "attr"ibute
  7378.  
  7379. [SEE-ALSO]
  7380.  
  7381. [EXAMPLE]
  7382.  
  7383. -*)
  7384.  
  7385. Procedure RegionFillAttr(         X1             : BYTE;
  7386.                                   Y1             : BYTE;
  7387.                                   X2             : BYTE;
  7388.                                   Y2             : BYTE;
  7389.                                   Attr           : BYTE      );
  7390.  
  7391. BEGIN
  7392.  
  7393.    VOutFillRegionAttr( CrtOCH, X1, Y1, X2, Y2, Attr );
  7394.  
  7395.  
  7396. END;  { RegionFillAttr }
  7397.  
  7398.  
  7399. {────────────────────────────────────────────────────────────────────────────}
  7400.  
  7401. (*-
  7402.  
  7403. [FUNCTION]
  7404.  
  7405. Procedure RegionFillColors(       X1             : BYTE;
  7406.                                   Y1             : BYTE;
  7407.                                   X2             : BYTE;
  7408.                                   Y2             : BYTE;
  7409.                                   F              : BYTE;
  7410.                                   B              : BYTE      );
  7411.  
  7412. [PARAMETERS]
  7413.  
  7414. X1          Left Screen Region Coordinate
  7415. Y1          Top Screen Region Coordinate
  7416. X2          Right Region Screen Region Coordinate
  7417. Y2          Bottom Screen Region Coordinate
  7418. F           Foreground Color to Fill Region With
  7419. B           Background Color to Fill Region With
  7420.  
  7421. [RETURNS]
  7422.  
  7423. (None)
  7424.  
  7425. [DESCRIPTION]
  7426.  
  7427. Fills the specified region with the specified "F"oregound
  7428. and "B"ackground colors.
  7429.  
  7430. [SEE-ALSO]
  7431.  
  7432. [EXAMPLE]
  7433.  
  7434. -*)
  7435.  
  7436.  
  7437. Procedure RegionFillColors(       X1             : BYTE;
  7438.                                   Y1             : BYTE;
  7439.                                   X2             : BYTE;
  7440.                                   Y2             : BYTE;
  7441.                                   F              : BYTE;
  7442.                                   B              : BYTE      );
  7443.  
  7444. Var
  7445.   X : Byte;
  7446.   Y : Byte;
  7447.  
  7448. BEGIN
  7449.  
  7450.    VOutFillRegionAttr( CrtOCH, X1, Y1, X2, Y2, ((B AND $07) shl 4) + F );
  7451.  
  7452.    (*
  7453.    For Y := Y1 TO Y2 DO
  7454.       For X:= X1 TO X2 DO
  7455.          VOutAttrWrite( CrtOCH, X,Y,(B shl 4) + F);
  7456.    *)
  7457.  
  7458. END;  { RegionFillAttr }
  7459.  
  7460.  
  7461. {────────────────────────────────────────────────────────────────────────────}
  7462.  
  7463. (*-
  7464.  
  7465. [FUNCTION]
  7466.  
  7467. Procedure RegionFillChar(         X1             : BYTE;
  7468.                                   Y1             : BYTE;
  7469.                                   X2             : BYTE;
  7470.                                   Y2             : BYTE;
  7471.                                   Ch             : CHAR      );
  7472.  
  7473. [PARAMETERS]
  7474.  
  7475. X1          Left Screen Region Coordinate
  7476. Y1          Top Screen Region Coordinate
  7477. X2          Right Region Screen Region Coordinate
  7478. Y2          Bottom Screen Region Coordinate
  7479. Ch          Character Pattern to Fill Region with
  7480.  
  7481. [RETURNS]
  7482.  
  7483. (None)
  7484.  
  7485. [DESCRIPTION]
  7486.  
  7487. Fills the specified region with the specified character.
  7488.  
  7489. [SEE-ALSO]
  7490.  
  7491. [EXAMPLE]
  7492.  
  7493. -*)
  7494.  
  7495. Procedure RegionFillChar(         X1             : BYTE;
  7496.                                   Y1             : BYTE;
  7497.                                   X2             : BYTE;
  7498.                                   Y2             : BYTE;
  7499.                                   Ch             : CHAR      );
  7500.  
  7501. BEGIN
  7502.  
  7503.    VOutFillRegionChar( CrtOCH, X1, Y1, X2, Y2, CH );
  7504.  
  7505. END;  { RegionFillChar }
  7506.  
  7507. {────────────────────────────────────────────────────────────────────────────}
  7508.  
  7509. (*-
  7510.  
  7511. [FUNCTION]
  7512.  
  7513. Procedure RepeatChar(             Ch             : CHAR;
  7514.                                   Num            : WORD      );
  7515.  
  7516. [PARAMETERS]
  7517.  
  7518. Ch          Character to Write
  7519. Num         Number of times to Write Character
  7520.  
  7521. [RETURNS]
  7522.  
  7523. (None)
  7524.  
  7525. [DESCRIPTION]
  7526.  
  7527. Writes a Character a repeated number of times starting at the current
  7528. cursor position using the current colors.
  7529.  
  7530. Repeats a "Ch"aracter a "Num"ber of times at the current Cursor
  7531. location in the current colors.
  7532.  
  7533. [SEE-ALSO]
  7534.  
  7535. [EXAMPLE]
  7536.  
  7537. -*)
  7538.  
  7539. Procedure RepeatChar(             Ch             : CHAR;
  7540.                                   Num            : WORD      );
  7541.  
  7542. BEGIN
  7543.  
  7544.   While (Num > 0) Do
  7545.   BEGIN
  7546.  
  7547.     Write( CH );
  7548.     Dec( Num );
  7549.  
  7550.   END;  { While Num }
  7551.  
  7552. END;  { RepeatChar }
  7553.  
  7554. {────────────────────────────────────────────────────────────────────────────}
  7555.  
  7556. (*-
  7557.  
  7558. [FUNCTION]
  7559.  
  7560. Procedure RepeatCharAt(           X1             : BYTE;
  7561.                                   Y1             : BYTE;
  7562.                                   F              : BYTE;
  7563.                                   B              : BYTE;
  7564.                                   Ch             : CHAR;
  7565.                                   Num            : WORD      );
  7566.  
  7567. [PARAMETERS]
  7568.  
  7569. X1          X Screen Coordinate
  7570. Y1          Y Screen Coordinate
  7571. F           Foreground Color
  7572. B           Background Color
  7573. Ch          Character to Write
  7574. Num         Number of Times to Write Character
  7575.  
  7576. [RETURNS]
  7577.  
  7578. (None)
  7579.  
  7580. [DESCRIPTION]
  7581.  
  7582. Writes a Character a repeated number of times starting at a given Coordinate
  7583. with the provided Colors.
  7584.  
  7585. Repeats a character the specified number of times at the specified
  7586. X/Y locations and with the specified colors.
  7587.  
  7588. [SEE-ALSO]
  7589.  
  7590. [EXAMPLE]
  7591.  
  7592. -*)
  7593.  
  7594. Procedure RepeatCharAt(           X1             : BYTE;
  7595.                                   Y1             : BYTE;
  7596.                                   F              : BYTE;
  7597.                                   B              : BYTE;
  7598.                                   Ch             : CHAR;
  7599.                                   Num            : WORD      );
  7600.  
  7601. Var
  7602.   SaveX, SaveY, SaveF, SaveB : BYTE;
  7603.  
  7604. BEGIN
  7605.  
  7606.   SaveX := WhereX;
  7607.   SaveY := WhereY;
  7608.   SaveF := TextColorGet;
  7609.   SaveB := TextBackgroundGet;
  7610.  
  7611.   GotoXY( X1, Y1 );
  7612.  
  7613.   TextColor( F );
  7614.   TextBackGround( B );
  7615.  
  7616.   RepeatChar( Ch, Num );
  7617.  
  7618.   GotoXY( SaveX, SaveY );
  7619.  
  7620.   TextColor( SaveF );
  7621.   TextBackGround( SaveB );
  7622.  
  7623. END;  { RepeatCharAt }
  7624.  
  7625. {────────────────────────────────────────────────────────────────────────────}
  7626.  
  7627. (*-
  7628.  
  7629. [FUNCTION]
  7630.  
  7631. Procedure WriteCharAt(            X1             : BYTE;
  7632.                                   Y1             : BYTE;
  7633.                                   F              : BYTE;
  7634.                                   B              : BYTE;
  7635.                                   Ch             : CHAR      );
  7636.  
  7637. [PARAMETERS]
  7638.  
  7639. X1          X Screen Coordinate
  7640. Y1          Y Screen Coordinate
  7641. F           Foreground Color
  7642. B           Background Color
  7643. Ch          Character to Write
  7644.  
  7645. [RETURNS]
  7646.  
  7647. (None)
  7648.  
  7649. [DESCRIPTION]
  7650.  
  7651. Writes a single Character at the given screen coordinates using a
  7652. provided colors.
  7653.  
  7654. Writes a specified "ch"aracter at a specified X/Y location in the
  7655. specified colors.
  7656.  
  7657. [SEE-ALSO]
  7658.  
  7659. [EXAMPLE]
  7660.  
  7661. -*)
  7662.  
  7663. Procedure WriteCharAt(            X1             : BYTE;
  7664.                                   Y1             : BYTE;
  7665.                                   F              : BYTE;
  7666.                                   B              : BYTE;
  7667.                                   Ch             : CHAR      );
  7668.  
  7669. BEGIN
  7670.  
  7671.   VOutWriteCharAt( CrtOCH, X1, Y1, F, B, Ch );
  7672.  
  7673. END;  { WriteCharAt }
  7674.  
  7675. {────────────────────────────────────────────────────────────────────────────}
  7676.  
  7677. (*-
  7678.  
  7679. [FUNCTION]
  7680.  
  7681. Procedure WriteStringAt(          X1             : BYTE;
  7682.                                   Y1             : BYTE;
  7683.                                   F              : BYTE;
  7684.                                   B              : BYTE;
  7685.                                   S              : STRING    );
  7686.  
  7687. [PARAMETERS]
  7688.  
  7689. X1          X Screen Coordinate
  7690. Y1          Y Screen Coordinate
  7691. F           Foreground Color
  7692. B           Background Color
  7693. S           String to Write
  7694.  
  7695. [RETURNS]
  7696.  
  7697. (None)
  7698.  
  7699. [DESCRIPTION]
  7700.  
  7701. Writes a String at the given coordinates using the provided colors.
  7702.  
  7703. Writes a specified "S"tring at a specified X/Y location in the
  7704. specified colors.  Same as a "FastWrite".
  7705.  
  7706. [SEE-ALSO]
  7707.  
  7708. [EXAMPLE]
  7709.  
  7710. -*)
  7711.  
  7712. Procedure WriteStringAt(          X1             : BYTE;
  7713.                                   Y1             : BYTE;
  7714.                                   F              : BYTE;
  7715.                                   B              : BYTE;
  7716.                                   S              : STRING    );
  7717. BEGIN
  7718.  
  7719.   VOutWriteStringAt( CrtOCH, X1, Y1, F, B, S );
  7720.  
  7721. END;  { WriteStringAt }
  7722.  
  7723. {────────────────────────────────────────────────────────────────────────────}
  7724.  
  7725. (*-
  7726.  
  7727. [FUNCTION]
  7728.  
  7729. Procedure WriteRepeatString(           RepCount  : WORD;
  7730.                                        S         : STRING    );
  7731.  
  7732. [PARAMETERS]
  7733.  
  7734. repcount    number of times to repeat the string
  7735. s           the string to write repeatedly
  7736.  
  7737. [RETURNS]
  7738.  
  7739. (None)
  7740.  
  7741. [DESCRIPTION]
  7742.  
  7743. Writes a String repeatedly, starting at the current cursor location,
  7744. and in the current attribute.
  7745.  
  7746. [SEE-ALSO]
  7747.  
  7748. [EXAMPLE]
  7749.  
  7750.   WriteRepeatString( 3, 'Hey! ');
  7751.  
  7752.   Would output:
  7753.  
  7754.     Hey! Hey! Hey!
  7755.  
  7756. -*)
  7757.  
  7758.  
  7759. Procedure WriteRepeatString(           RepCount  : WORD;
  7760.                                        S         : STRING    );
  7761.  
  7762. BEGIN
  7763.  
  7764.   VOutRepeatString( CrtOCH, RepCount, S );
  7765.  
  7766. END;
  7767.  
  7768. {────────────────────────────────────────────────────────────────────────────}
  7769.  
  7770. (*-
  7771.  
  7772. [FUNCTION]
  7773. Procedure CursorType(                  CurType   : WORD );
  7774.  
  7775.  
  7776. [PARAMETERS]
  7777.  
  7778. curtype     cursor type to use, can be:
  7779.  
  7780.               cctNone   = 0;     { no visible cursor              }
  7781.               cctSmall  = 1;     { "normal cursor"                }
  7782.               cctHalf   = 2;     { half-height cursor             }
  7783.               cctBig    = 3;     { Full-height "overwrite" cursor }
  7784.  
  7785.  
  7786. [RETURNS]
  7787.  
  7788. (None)
  7789.  
  7790. [DESCRIPTION]
  7791.  
  7792. Sets the visible cursor type.
  7793.  
  7794. [SEE-ALSO]
  7795.  
  7796. [EXAMPLE]
  7797.  
  7798.  
  7799. -*)
  7800.  
  7801.  
  7802. Procedure CursorType(                  CurType   : WORD );
  7803.  
  7804. BEGIN
  7805.  
  7806.   VOutSetCursorType( CrtOCH, CurType );
  7807.  
  7808. END;
  7809.  
  7810. {────────────────────────────────────────────────────────────────────────────}
  7811.  
  7812. (*-
  7813.  
  7814. [FUNCTION]
  7815.  
  7816. Procedure CursorOn;
  7817.  
  7818. [PARAMETERS]
  7819.  
  7820.  
  7821. [RETURNS]
  7822.  
  7823. (None)
  7824.  
  7825. [DESCRIPTION]
  7826.  
  7827. Sets the visible cursor type to ON (normal-two line cusor)
  7828.  
  7829. [SEE-ALSO]
  7830.  
  7831. [EXAMPLE]
  7832.  
  7833.  
  7834. -*)
  7835.  
  7836.  
  7837. Procedure CursorOn;
  7838.  
  7839. BEGIN
  7840.  
  7841.   VOutSetCursorType( CrtOCH, cctSmall );
  7842.  
  7843. END;
  7844.  
  7845. {────────────────────────────────────────────────────────────────────────────}
  7846.  
  7847. (*-
  7848.  
  7849. [FUNCTION]
  7850.  
  7851. Procedure CursorOff;
  7852.  
  7853. [PARAMETERS]
  7854.  
  7855.  
  7856. [RETURNS]
  7857.  
  7858. (None)
  7859.  
  7860. [DESCRIPTION]
  7861.  
  7862. Sets the visible cursor type to OFF (no cursor)
  7863.  
  7864. [SEE-ALSO]
  7865.  
  7866. [EXAMPLE]
  7867.  
  7868.  
  7869. -*)
  7870.  
  7871.  
  7872.  
  7873. Procedure CursorOff;
  7874.  
  7875. BEGIN
  7876.  
  7877.   VOutSetCursorType( CrtOCH, cctNone );
  7878.  
  7879. END;
  7880.  
  7881. {────────────────────────────────────────────────────────────────────────────}
  7882.  
  7883. (*-
  7884.  
  7885. [FUNCTION]
  7886.  
  7887. Procedure CursorSmall
  7888.  
  7889. [PARAMETERS]
  7890.  
  7891.  
  7892. [RETURNS]
  7893.  
  7894. (None)
  7895.  
  7896. [DESCRIPTION]
  7897.  
  7898. Sets the visible cursor type to SMALL (normal-two line cusor)
  7899.  
  7900. [SEE-ALSO]
  7901.  
  7902. [EXAMPLE]
  7903.  
  7904.  
  7905. -*)
  7906.  
  7907.  
  7908. Procedure CursorSmall;
  7909.  
  7910. BEGIN
  7911.  
  7912.   VOutSetCursorType( CrtOCH, cctSmall );
  7913.  
  7914. END;
  7915.  
  7916. {────────────────────────────────────────────────────────────────────────────}
  7917.  
  7918. (*-
  7919.  
  7920. [FUNCTION]
  7921.  
  7922. Procedure CursorHalf;
  7923.  
  7924. [PARAMETERS]
  7925.  
  7926.  
  7927. [RETURNS]
  7928.  
  7929. (None)
  7930.  
  7931. [DESCRIPTION]
  7932.  
  7933. Sets the visible cursor type to HALF (half-height cusor)
  7934.  
  7935. [SEE-ALSO]
  7936.  
  7937. [EXAMPLE]
  7938.  
  7939.  
  7940. -*)
  7941.  
  7942.  
  7943. Procedure CursorHalf;
  7944.  
  7945. BEGIN
  7946.  
  7947.   VOutSetCursorType( CrtOCH, cctHalf );
  7948.  
  7949. END;
  7950.  
  7951. {────────────────────────────────────────────────────────────────────────────}
  7952.  
  7953. (*-
  7954.  
  7955. [FUNCTION]
  7956.  
  7957. Procedure CursorBig;
  7958.  
  7959. [PARAMETERS]
  7960.  
  7961.  
  7962. [RETURNS]
  7963.  
  7964. (None)
  7965.  
  7966. [DESCRIPTION]
  7967.  
  7968. Sets the visible cursor type to BIG (full-height "overwrite" cursor )
  7969.  
  7970. [SEE-ALSO]
  7971.  
  7972. [EXAMPLE]
  7973.  
  7974.  
  7975. -*)
  7976.  
  7977.  
  7978.  
  7979. Procedure CursorBig;
  7980.  
  7981. BEGIN
  7982.  
  7983.   VOutSetCursorType( CrtOCH, cctBig );
  7984.  
  7985. END;
  7986.  
  7987. {────────────────────────────────────────────────────────────────────────────}
  7988.  
  7989.  
  7990. (*-
  7991.  
  7992. [FUNCTION]
  7993.  
  7994. Function  MakeAttr(                    F         : INTEGER;
  7995.                                        B         : INTEGER   ) : BYTE;
  7996.  
  7997. [PARAMETERS]
  7998.  
  7999. F           foreground color to use (-1 to use current foreground)
  8000. B           background color to use (-1 to use current background)
  8001.  
  8002. [RETURNS]
  8003.  
  8004. (None)
  8005.  
  8006. [DESCRIPTION]
  8007.  
  8008. This function makes an attribute byte from the specified foreground
  8009. and background colors.  To use the current foreground color,
  8010. "F" should be -1.  To use the current background color, "B" should
  8011. be -1.
  8012.  
  8013. [SEE-ALSO]
  8014.  
  8015. [EXAMPLE]
  8016.  
  8017.  
  8018. -*)
  8019.  
  8020.  
  8021.  
  8022.  
  8023.  
  8024. Function  MakeAttr(                    F         : INTEGER;
  8025.                                        B         : INTEGER   ) : BYTE;
  8026.  
  8027.  
  8028. BEGIN
  8029.  
  8030.   If F=-1 Then
  8031.     F := TextAttr AND $0F;
  8032.  
  8033.   If B=-1 Then
  8034.     B := (TextAttr AND $80) SHR 4 ;
  8035.  
  8036.   MakeAttr := ((B AND $7) SHL 4) + (F AND $0F);
  8037.  
  8038. END;
  8039.  
  8040.  
  8041. (*-
  8042.  
  8043. [FUNCTION]
  8044.  
  8045. Procedure CRTLoadDefColorMap;
  8046.  
  8047. [PARAMETERS]
  8048.  
  8049. (None)
  8050.  
  8051. [RETURNS]
  8052.  
  8053. (None)
  8054.  
  8055. [DESCRIPTION]
  8056.  
  8057. [SEE-ALSO]
  8058.  
  8059. [EXAMPLE]
  8060.  
  8061. -*)
  8062.  
  8063. Procedure CRTLoadColorMap(   P : PCRTColorMap    );
  8064.  
  8065. BEGIN
  8066.  
  8067.   Move( P^, CRTColorMap, 256 );
  8068.  
  8069. END;
  8070.  
  8071.  
  8072.  
  8073. Procedure CRTLoadMonoColorMap;
  8074.  
  8075. BEGIN
  8076.  
  8077.   CRTLoadColorMap( @MonoMap );
  8078.  
  8079. END;
  8080.  
  8081.  
  8082. Procedure CRTLoadDefColorMap;
  8083.  
  8084. Var
  8085.  
  8086.   Z : INTEGER;
  8087.  
  8088. BEGIN
  8089.  
  8090.  
  8091.   If CRTIsMono Then
  8092.   BEGIN
  8093.  
  8094.     CRTLoadMonoColorMap;
  8095.  
  8096.   END  { If CRTIsMono }
  8097.   Else
  8098.   BEGIN
  8099.  
  8100.     For Z:=0 to 255 Do
  8101.       CRTColorMap[ Z ] := Z;
  8102.  
  8103.   END;  { If CRTIsMono / Else }
  8104.  
  8105. END;  { CRTLoadDefColorMap }
  8106.  
  8107. (*
  8108. Procedure MySend( Idata : POINTER; St : STRING ); Far;
  8109.  
  8110. Var
  8111.   R : REGISTERS;
  8112. BEGIN
  8113.  
  8114.   R.AH := $40;
  8115.   R.BX := 1;
  8116.   R.CX := Byte(ST[0] );;
  8117.   R.DS := Seg( ST[1]  );
  8118.   R.DX := Ofs( ST[1]  );
  8119.  
  8120.   Intr( $21, R );
  8121.  
  8122.   Write( tf, ST );
  8123.  
  8124. END;
  8125. *)
  8126.  
  8127. {────────────────────────────────────────────────────────────────────────────}
  8128. {────────────────────────────────────────────────────────────────────────────}
  8129. {────────────────────────────────────────────────────────────────────────────}
  8130.  
  8131. BEGIN
  8132.  
  8133.  
  8134.     {$IFDEF DEBUG }
  8135.       DebugOpen( 'VCRT.OUT' );
  8136.       DebugWriteLn('Debug output started.');
  8137.       DebugWriteLn('VCRT Unit Init Procedure:');
  8138.     {$ENDIF}
  8139.  
  8140.   {---------------------------------------}
  8141.   { Do the delay timing loop and load the }
  8142.   { default CRT colormap                  }
  8143.   {---------------------------------------}
  8144.  
  8145. {$IFNDEF OS2}
  8146.   FindDelay;
  8147. {$ENDIF}
  8148.  
  8149.   CRTLoadDefColorMap;
  8150.  
  8151.   {-----------}
  8152.   { Init vars }
  8153.   {-----------}
  8154.  
  8155.   CheckBreak    := TRUE;
  8156.   CheckEOF      := FALSE;
  8157.  
  8158.   { get text attr somehow }
  8159.  
  8160.   TextAttr := 1;
  8161.  
  8162.   KnownTextAttr := TextAttr;
  8163.  
  8164.   {$IFDEF DEBUG }
  8165.     DebugWriteLn('VoutChannelNew');
  8166.   {$ENDIF}
  8167.  
  8168.   {----------------------------------}
  8169.   { Allocate the IN and OUT channels }
  8170.   {----------------------------------}
  8171.  
  8172.   CrtOCH := VOutChannelNew( 0, 'VCRT' );
  8173.  
  8174.  
  8175.   {---------------------------------------}
  8176.   { create an output sub-channel attached }
  8177.   { to the CRT/Bx00 video memory          }
  8178.   { output driver.                        }
  8179.   {---------------------------------------}
  8180.  
  8181.  
  8182. {$IFNDEF OS2}
  8183.  
  8184.  
  8185.   {$IFDEF DEBUG }
  8186.     DebugWriteLn('VOutSubChannelNew( CRTOutProc )');
  8187.   {$ENDIF}
  8188.  
  8189.   VOutSubChannelNew( CrtOCH,
  8190.                      0,
  8191.                      'Bx00VMEM',
  8192.                      CRTOutDriverProc,
  8193.                      0, 0, 0              );
  8194.  
  8195. {$ELSE}
  8196.  
  8197.   {$IFDEF DEBUG }
  8198.     DebugWriteLn('VOutSubChannelNew( VIOOutDriverProc )');
  8199.   {$ENDIF}
  8200.  
  8201.  
  8202.   VOutSubChannelNew( CrtOCH,
  8203.                      0,
  8204.                      'Bx00VMEM',
  8205.                      VIOOutDriverProc,
  8206.                      0, 0, 0              );
  8207.  
  8208.  
  8209.  
  8210. {$ENDIF}
  8211.  
  8212.  
  8213. (*
  8214. VOutSubChannelNew( CrtOCH,
  8215.                      0,
  8216.                      'Bx00VMEM',
  8217.                      CrtOutDriverProc,
  8218.                      0, 0, 0               );
  8219. *)
  8220.  
  8221.  
  8222. (*
  8223.   VOutSubChannelNew( CrtOCH,
  8224.                      0,
  8225.                      'Bx00VMEM',
  8226.                      ANSIOutDriverProc,
  8227.                      0,0,0                     );
  8228.  
  8229.  
  8230.  
  8231.  
  8232.   VOutFilterAttach( CrtOCH,
  8233.                     0,
  8234.                     'VACKY!',
  8235.                     'Bx00VMEM',
  8236.                     VirtScreenFilter,
  8237.                     0, 0, 0                );
  8238.  
  8239. *)
  8240.  
  8241.   {$IFDEF DEBUG }
  8242.     DebugWriteLn('VInDriverNew');
  8243.   {$ENDIF}
  8244.  
  8245.   VInDriverNew(  CRTInDriverProc,
  8246.                  'VCRTInDP',
  8247.                  NIL,
  8248.                  CRTODNErr                    );
  8249.  
  8250.   {$IFDEF DEBUG }
  8251.     DebugWriteLn('VOutGetScreenSize');
  8252.   {$ENDIF}
  8253.  
  8254.  
  8255.   VOutGetScreenSize( CrtOCH, ScreenRows, ScreenCols );
  8256.  
  8257.   (*
  8258.   ScreenCols := 80;
  8259.   ScreenRows := 25;
  8260.   *)
  8261.  
  8262.   WindMin := 0;
  8263.   WindMax := ((ScreenRows-1) SHL 8) + ScreenCols-1;
  8264.  
  8265.   {-------------------------}
  8266.   { Assign INPUT and OUTPUT }
  8267.   {-------------------------}
  8268.  
  8269.   AssignCRT( Input );
  8270.   Reset    ( Input );
  8271.  
  8272.   AssignCRT( Output );
  8273.   Rewrite  ( Output );
  8274.  
  8275. END.
  8276.  
  8277.   (*
  8278.  
  8279.   Output driver types:
  8280.  
  8281.  
  8282.     OutDirect        output direct to video memory
  8283.  
  8284.     OutBios          output to BIOS int 10h
  8285.  
  8286.     OutDosAnsi       output to DOS / use ANSI commands
  8287.  
  8288.     OutDosAvatar     output to DOS / use AVATAR commands
  8289.  
  8290.     OutTPcrt         output through Turbo Pascals CRT unit
  8291.  
  8292.     OutOPcrt         output through Object Professionals OpCRT unit
  8293.  
  8294.     OutSerAnsi       output to Serial Channel / Use ANSI commands
  8295.  
  8296.     OutSerAvatar     output to Serial Channel / Use Avatar commands
  8297.  
  8298.     OutSerVioPro     output to Serial Channel / Use Visionix I/O Protocol
  8299.  
  8300.  
  8301.  
  8302.   Input driver types:
  8303.  
  8304.     InDirect         Input direct from keyboard
  8305.  
  8306.     InBios           Input from BIOS
  8307.  
  8308.     InTPcrt          Input from TPCRT
  8309.  
  8310.     inOPcrt          Input from Object pro CRT
  8311.  
  8312.     InDos            Input from DOS
  8313.  
  8314.     InSer            Input from serial port
  8315.  
  8316.  
  8317.  
  8318.  
  8319. Avatar
  8320.  
  8321.    ^V  ^A
  8322.        ^B
  8323.        ^C
  8324.        ^D
  8325.  
  8326. *)
  8327.